yobx.sklearn.tree.decision_tree#

yobx.sklearn.tree.decision_tree.sklearn_decision_tree_classifier(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: DecisionTreeClassifier, X: str, name: str = 'decision_tree_classifier') Tuple[str, str][source]#

Converts a sklearn.tree.DecisionTreeClassifier into ONNX.

When ai.onnx.ml opset 5 (or later) is active in the graph builder the unified TreeEnsemble operator is used; otherwise the legacy TreeEnsembleClassifier operator is emitted.

Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • estimator – a fitted DecisionTreeClassifier

  • outputs – desired names (label, probabilities)

  • X – input tensor name

  • name – prefix names for the added nodes

Returns:

tuple (label_result_name, proba_result_name)

yobx.sklearn.tree.decision_tree.sklearn_decision_tree_regressor(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: DecisionTreeRegressor, X: str, name: str = 'decision_tree_regressor') str[source]#

Converts a sklearn.tree.DecisionTreeRegressor into ONNX.

When ai.onnx.ml opset 5 (or later) is active in the graph builder the unified TreeEnsemble operator is used; otherwise the legacy TreeEnsembleRegressor operator is emitted.

When the input tensor is double (float64), a Cast node is appended after the tree operator to ensure the output dtype matches the input dtype, since both TreeEnsembleRegressor and TreeEnsemble always produce float32 predictions per the ONNX ML spec.

Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • estimator – a fitted DecisionTreeRegressor

  • outputs – desired output names (predictions)

  • X – input tensor name

  • name – prefix names for the added nodes

Returns:

output tensor name