module onnxrt.ops_cpu.op_tree_ensemble_regressor#

Inheritance diagram of mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor

Short summary#

module mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor

Runtime operator.

source on GitHub

Classes#

class

truncated documentation

TreeEnsembleRegressor_1

TreeEnsembleRegressor_3

TreeEnsembleRegressor (ai.onnx.ml) ================================== Tree Ensemble regressor. Returns the regressed …

TreeEnsembleRegressor_3

TreeEnsembleRegressor (ai.onnx.ml) ================================== Tree Ensemble regressor. Returns the regressed …

TreeEnsembleRegressorCommon

TreeEnsembleRegressorDouble

Runtime for the custom operator TreeEnsembleRegressorDouble.

TreeEnsembleRegressorDoubleSchema

Defines a schema for operators added in this package such as TreeEnsembleRegressorDouble.

Properties#

property

truncated documentation

args_default

Returns the list of arguments as well as the list of parameters with the default values (close to the signature). …

args_default

Returns the list of arguments as well as the list of parameters with the default values (close to the signature). …

args_default

Returns the list of arguments as well as the list of parameters with the default values (close to the signature). …

args_default

Returns the list of arguments as well as the list of parameters with the default values (close to the signature). …

args_default

Returns the list of arguments as well as the list of parameters with the default values (close to the signature). …

args_default_modified

Returns the list of modified parameters.

args_default_modified

Returns the list of modified parameters.

args_default_modified

Returns the list of modified parameters.

args_default_modified

Returns the list of modified parameters.

args_default_modified

Returns the list of modified parameters.

args_mandatory

Returns the list of optional arguments.

args_mandatory

Returns the list of optional arguments.

args_mandatory

Returns the list of optional arguments.

args_mandatory

Returns the list of optional arguments.

args_mandatory

Returns the list of optional arguments.

args_optional

Returns the list of optional arguments.

args_optional

Returns the list of optional arguments.

args_optional

Returns the list of optional arguments.

args_optional

Returns the list of optional arguments.

args_optional

Returns the list of optional arguments.

atts_value

Returns all parameters in a dictionary.

atts_value

Returns all parameters in a dictionary.

atts_value

Returns all parameters in a dictionary.

atts_value

Returns all parameters in a dictionary.

atts_value

Returns all parameters in a dictionary.

Methods#

method

truncated documentation

__init__

__init__

__init__

__init__

__init__

__init__

_find_custom_operator_schema

Finds a custom operator defined by this runtime.

_find_custom_operator_schema

Finds a custom operator defined by this runtime.

_find_custom_operator_schema

Finds a custom operator defined by this runtime.

_find_custom_operator_schema

Finds a custom operator defined by this runtime.

_find_custom_operator_schema

Finds a custom operator defined by this runtime.

_get_typed_attributes

_get_typed_attributes

_get_typed_attributes

_get_typed_attributes

_get_typed_attributes

_init

_init

_init

_init

_init

_run

This is a C++ implementation coming from onnxruntime. tree_ensemble_classifier.cc. …

_run

This is a C++ implementation coming from onnxruntime. tree_ensemble_classifier.cc. …

_run

This is a C++ implementation coming from onnxruntime. tree_ensemble_classifier.cc. …

_run

This is a C++ implementation coming from onnxruntime. tree_ensemble_classifier.cc. …

_run

This is a C++ implementation coming from onnxruntime. tree_ensemble_classifier.cc. …

Documentation#

Runtime operator.

source on GitHub

mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor.TreeEnsembleRegressor#

alias of TreeEnsembleRegressor_3

class mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor.TreeEnsembleRegressorCommon(dtype, onnx_node, desc=None, expected_attributes=None, runtime_version=3, **options)#

Bases: OpRunUnaryNum

__init__(dtype, onnx_node, desc=None, expected_attributes=None, runtime_version=3, **options)#
_find_custom_operator_schema(op_name)#

Finds a custom operator defined by this runtime.

source on GitHub

_get_typed_attributes(k)#
_init(dtype, version)#
_run(x, attributes=None, verbose=0, fLOG=None)#

This is a C++ implementation coming from onnxruntime. tree_ensemble_classifier.cc. See class RuntimeTreeEnsembleRegressorFloat or class RuntimeTreeEnsembleRegressorDouble.

source on GitHub

class mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor.TreeEnsembleRegressorDouble(onnx_node, desc=None, runtime_version=1, **options)#

Bases: TreeEnsembleRegressorCommon

Runtime for the custom operator TreeEnsembleRegressorDouble. .. exref:

:title: How to use TreeEnsembleRegressorDouble instead of TreeEnsembleRegressor
.. runpython::
    :showcode:
    import warnings
    import numpy
    from sklearn.datasets import make_regression
    from sklearn.ensemble import (
        RandomForestRegressor, GradientBoostingRegressor,
        HistGradientBoostingRegressor)
    from mlprodict.onnx_conv import to_onnx
    from mlprodict.onnxrt import OnnxInference
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        models = [
            RandomForestRegressor(n_estimators=10),
            GradientBoostingRegressor(n_estimators=10),
            HistGradientBoostingRegressor(max_iter=10),
        ]
        X, y = make_regression(1000, n_features=5, n_targets=1)
        X = X.astype(numpy.float64)
        conv = {}
        for model in models:
            model.fit(X[:500], y[:500])
            onx64 = to_onnx(model, X, rewrite_ops=True, target_opset=15)
            assert 'TreeEnsembleRegressorDouble' in str(onx64)
            expected = model.predict(X)
            oinf = OnnxInference(onx64)
            got = oinf.run({'X': X})
            diff = numpy.abs(got['variable'] - expected)
            print("%s: max=%f mean=%f" % (
                model.__class__.__name__, diff.max(), diff.mean()))

source on GitHub

__init__(onnx_node, desc=None, runtime_version=1, **options)#
class mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor.TreeEnsembleRegressorDoubleSchema#

Bases: OperatorSchema

Defines a schema for operators added in this package such as TreeEnsembleRegressorDouble.

source on GitHub

__init__()#
class mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor.TreeEnsembleRegressor_1(onnx_node, desc=None, runtime_version=1, **options)#

Bases: TreeEnsembleRegressorCommon

__init__(onnx_node, desc=None, runtime_version=1, **options)#
class mlprodict.onnxrt.ops_cpu.op_tree_ensemble_regressor.TreeEnsembleRegressor_3(onnx_node, desc=None, runtime_version=1, **options)#

Bases: TreeEnsembleRegressorCommon

TreeEnsembleRegressor (ai.onnx.ml)#

Tree Ensemble regressor. Returns the regressed values for each input in N.

All args with nodes_ are fields of a tuple of tree nodes, and it is assumed they are the same length, and an index i will decode the tuple across these inputs. Each node id can appear only once for each tree id.

All fields prefixed with target_ are tuples of votes at the leaves.

A leaf may have multiple votes, where each vote is weighted by the associated target_weights index.

All fields ending with <i>_as_tensor</i> can be used instead of the same parameter without the suffix if the element type is double and not float. All trees must have their node ids start at 0 and increment by 1.

Mode enum is BRANCH_LEQ, BRANCH_LT, BRANCH_GTE, BRANCH_GT, BRANCH_EQ, BRANCH_NEQ, LEAF

Attributes

  • aggregate_function: Defines how to aggregate leaf values within a target. One of ‘AVERAGE,’ ‘SUM,’ ‘MIN,’ ‘MAX.’ Default value is nameaggregatefunctionsSUMtypeSTRING (STRING)

  • base_values: Base values for classification, added to final class score; the size must be the same as the classes or can be left unassigned (assumed 0) default value cannot be automatically retrieved (FLOATS)

  • base_values_as_tensor: Base values for classification, added to final class score; the size must be the same as the classes or can be left unassigned (assumed 0) default value cannot be automatically retrieved (TENSOR)

  • n_targets: The total number of targets. default value cannot be automatically retrieved (INT)

  • nodes_falsenodeids: Child node if expression is false default value cannot be automatically retrieved (INTS)

  • nodes_featureids: Feature id for each node. default value cannot be automatically retrieved (INTS)

  • nodes_hitrates: Popularity of each node, used for performance and may be omitted. default value cannot be automatically retrieved (FLOATS)

  • nodes_hitrates_as_tensor: Popularity of each node, used for performance and may be omitted. default value cannot be automatically retrieved (TENSOR)

  • nodes_missing_value_tracks_true: For each node, define what to do in the presence of a NaN: use the ‘true’ (if the attribute value is 1) or ‘false’ (if the attribute value is 0) branch based on the value in this array. This attribute may be left undefined and the defalt value is false (0) for all nodes. default value cannot be automatically retrieved (INTS)

  • nodes_modes: The node kind, that is, the comparison to make at the node. There is no comparison to make at a leaf node. One of ‘BRANCH_LEQ’, ‘BRANCH_LT’, ‘BRANCH_GTE’, ‘BRANCH_GT’, ‘BRANCH_EQ’, ‘BRANCH_NEQ’, ‘LEAF’ default value cannot be automatically retrieved (STRINGS)

  • nodes_nodeids: Node id for each node. Node ids must restart at zero for each tree and increase sequentially. default value cannot be automatically retrieved (INTS)

  • nodes_treeids: Tree id for each node. default value cannot be automatically retrieved (INTS)

  • nodes_truenodeids: Child node if expression is true default value cannot be automatically retrieved (INTS)

  • nodes_values: Thresholds to do the splitting on for each node. default value cannot be automatically retrieved (FLOATS)

  • nodes_values_as_tensor: Thresholds to do the splitting on for each node. default value cannot be automatically retrieved (TENSOR)

  • post_transform: Indicates the transform to apply to the score. One of ‘NONE,’ ‘SOFTMAX,’ ‘LOGISTIC,’ ‘SOFTMAX_ZERO,’ or ‘PROBIT’ Default value is nameposttransformsNONEtypeSTRING (STRING)

  • target_ids: The index of the target that each weight is for default value cannot be automatically retrieved (INTS)

  • target_nodeids: The node id of each weight default value cannot be automatically retrieved (INTS)

  • target_treeids: The id of the tree that each node is in. default value cannot be automatically retrieved (INTS)

  • target_weights: The weight for each target default value cannot be automatically retrieved (FLOATS)

  • target_weights_as_tensor: The weight for each target default value cannot be automatically retrieved (TENSOR)

Inputs

  • X (heterogeneous)T: Input of shape [N,F]

Outputs

  • Y (heterogeneous)tensor(float): N classes

Type Constraints

  • T tensor(float), tensor(double), tensor(int64), tensor(int32): The input type must be a tensor of a numeric type.

Version

Onnx name: TreeEnsembleRegressor

This version of the operator has been available since version 3 of domain ai.onnx.ml.

Runtime implementation: TreeEnsembleRegressor

__init__(onnx_node, desc=None, runtime_version=1, **options)#