yobx.sklearn.ensemble.random_forest#

yobx.sklearn.ensemble.random_forest.sklearn_extra_trees_classifier(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: ExtraTreesClassifier, X: str, name: str = 'extra_trees_classifier') Tuple[str, str][source]#

Converts a sklearn.ensemble.ExtraTreesClassifier into ONNX.

Extra Trees share the same internal tree structure as Random Forests (a list of fitted base estimators with a tree_ attribute). This converter therefore delegates entirely to the same attribute-extraction helpers used by sklearn_random_forest_classifier().

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 ExtraTreesClassifier

  • outputs – desired output names (label, probabilities)

  • X – input tensor name

  • name – prefix for node names added to the graph

Returns:

tuple (label_result_name, proba_result_name)

yobx.sklearn.ensemble.random_forest.sklearn_extra_trees_regressor(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: ExtraTreesRegressor, X: str, name: str = 'extra_trees_regressor') str[source]#

Converts a sklearn.ensemble.ExtraTreesRegressor into ONNX.

Extra Trees share the same internal tree structure as Random Forests. This converter delegates to the same attribute-extraction helpers used by sklearn_random_forest_regressor().

When ai.onnx.ml opset 5 (or later) is active in the graph builder the unified TreeEnsemble operator is used (leaf weights pre-divided by n_estimators so that SUM aggregation yields the average); otherwise the legacy TreeEnsembleRegressor operator is emitted with aggregate_function="AVERAGE".

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

  • sts – shapes defined by scikit-learn

  • estimator – a fitted ExtraTreesRegressor

  • outputs – desired output names (predictions)

  • X – input tensor name

  • name – prefix for node names added to the graph

Returns:

output tensor name

yobx.sklearn.ensemble.random_forest.sklearn_random_forest_classifier(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: RandomForestClassifier, X: str, name: str = 'random_forest_classifier') Tuple[str, str][source]#

Converts a sklearn.ensemble.RandomForestClassifier 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.

The forest is encoded as a single multi-tree ONNX node where each estimator’s leaf weights are divided by n_estimators so that the SUM aggregate (or NONE post-transform in the legacy path) yields the averaged class-probability vector used by predict_proba().

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

  • sts – shapes defined by scikit-learn

  • estimator – a fitted RandomForestClassifier

  • outputs – desired output names (label, probabilities)

  • X – input tensor name

  • name – prefix for node names added to the graph

Returns:

tuple (label_result_name, proba_result_name)

yobx.sklearn.ensemble.random_forest.sklearn_random_forest_regressor(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: RandomForestRegressor, X: str, name: str = 'random_forest_regressor') str[source]#

Converts a sklearn.ensemble.RandomForestRegressor into ONNX.

When ai.onnx.ml opset 5 (or later) is active in the graph builder the unified TreeEnsemble operator is used (leaf weights pre-divided by n_estimators so that SUM aggregation yields the average); otherwise the legacy TreeEnsembleRegressor operator is emitted with aggregate_function="AVERAGE".

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

  • sts – shapes defined by scikit-learn

  • estimator – a fitted RandomForestRegressor

  • outputs – desired output names (predictions)

  • X – input tensor name

  • name – prefix for node names added to the graph

Returns:

output tensor name