module sklapi.onnx_speed_up#

Inheritance diagram of mlprodict.sklapi.onnx_speed_up

Short summary#

module mlprodict.sklapi.onnx_speed_up

Speeding up scikit-learn with onnx.

Classes#

class

truncated documentation

_OnnxPipelineStepSpeedup

Speeds up inference by replacing methods transform or predict by a runtime for ONNX.

OnnxSpeedupClassifier

Trains with scikit-learn, transform with ONNX.

OnnxSpeedupCluster

Trains with scikit-learn, transform with ONNX.

OnnxSpeedupRegressor

Trains with scikit-learn, transform with ONNX.

OnnxSpeedupTransformer

Trains with scikit-learn, transform with ONNX.

Properties#

property

truncated documentation

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

op_version

Returns the opset version.

op_version

Returns the opset version.

op_version

Returns the opset version.

op_version

Returns the opset version.

op_version

Returns the opset version.

Methods#

method

truncated documentation

__getstate__

pickle does not support functions. This method removes any link to function when the runtime is …

__getstate__

pickle does not support functions. This method removes any link to function when the runtime is …

__getstate__

pickle does not support functions. This method removes any link to function when the runtime is …

__getstate__

pickle does not support functions. This method removes any link to function when the runtime is …

__getstate__

pickle does not support functions. This method removes any link to function when the runtime is …

__init__

__init__

__init__

__init__

__init__

__setstate__

pickle does not support functions. This method restores the function created when the runtime is …

__setstate__

pickle does not support functions. This method restores the function created when the runtime is …

__setstate__

pickle does not support functions. This method restores the function created when the runtime is …

__setstate__

pickle does not support functions. This method restores the function created when the runtime is …

__setstate__

pickle does not support functions. This method restores the function created when the runtime is …

_build_onnx_runtime

Returns an instance of OnnxTransformer which executes the ONNX graph.

_build_onnx_runtime

Returns an instance of OnnxTransformer which executes the ONNX graph.

_build_onnx_runtime

Returns an instance of OnnxTransformer which executes the ONNX graph.

_build_onnx_runtime

Returns an instance of OnnxTransformer which executes the ONNX graph.

_build_onnx_runtime

Returns an instance of OnnxTransformer which executes the ONNX graph.

_build_onnx_runtime_numpy

Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically …

_build_onnx_runtime_numpy

Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically …

_build_onnx_runtime_numpy

Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically …

_build_onnx_runtime_numpy

Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically …

_build_onnx_runtime_numpy

Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically …

_build_onnx_runtime_numpy_compile

Second part of _build_onnx_runtime_numpy().

_build_onnx_runtime_numpy_compile

Second part of _build_onnx_runtime_numpy().

_build_onnx_runtime_numpy_compile

Second part of _build_onnx_runtime_numpy().

_build_onnx_runtime_numpy_compile

Second part of _build_onnx_runtime_numpy().

_build_onnx_runtime_numpy_compile

Second part of _build_onnx_runtime_numpy().

_check_fitted_

_check_fitted_

_check_fitted_

_check_fitted_

_check_fitted_

_to_onnx

Converts an estimator inference into ONNX.

_to_onnx

Converts an estimator inference into ONNX.

_to_onnx

Converts an estimator inference into ONNX.

_to_onnx

Converts an estimator inference into ONNX.

_to_onnx

Converts an estimator inference into ONNX.

assert_almost_equal

Checks that ONNX and scikit-learn produces the same outputs.

assert_almost_equal

Checks that ONNX and scikit-learn produces the same outputs.

assert_almost_equal

Checks that ONNX and scikit-learn produces the same outputs.

assert_almost_equal

Checks that ONNX and scikit-learn produces the same outputs.

fit

Trains based estimator.

fit

Trains based estimator.

fit

Trains based estimator.

fit

Trains based estimator.

fit

Fits the estimator, converts to ONNX.

onnx_converter

Returns a converter for this transform.

onnx_converter

Returns a converter for this transform.

onnx_converter

Returns a converter for this transform.

onnx_converter

Returns a converter for this transform.

onnx_converter

Returns a converter for this transform.

onnx_parser

Returns a parser for this model.

onnx_parser

Returns a parser for this model.

onnx_parser

Returns a parser for this model.

onnx_parser

Returns a parser for this model.

onnx_parser

Returns a parser for this model.

onnx_shape_calculator

Returns a shape calculator for this transform.

onnx_shape_calculator

Returns a shape calculator for this transform.

onnx_shape_calculator

Returns a shape calculator for this transform.

onnx_shape_calculator

Returns a shape calculator for this transform.

onnx_shape_calculator

Returns a shape calculator for this transform.

predict

Transforms with ONNX.

predict

Transforms with ONNX.

predict

Transforms with ONNX.

predict_proba

Transforms with ONNX.

raw_predict

Transforms with scikit-learn.

raw_predict

Transforms with scikit-learn.

raw_predict

Transforms with scikit-learn.

raw_predict_proba

Transforms with scikit-learn.

raw_transform

Transforms with scikit-learn.

raw_transform

Transforms with scikit-learn.

transform

Transforms with ONNX.

transform

Transforms with ONNX.

Documentation#

Speeding up scikit-learn with onnx.

New in version 0.7.

source on GitHub

class mlprodict.sklapi.onnx_speed_up.OnnxSpeedupClassifier(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#

Bases: ClassifierMixin, _OnnxPipelineStepSpeedup

Trains with scikit-learn, transform with ONNX.

Parameters:
  • estimator – estimator to train

  • enforce_float32 – boolean onnxruntime only supports float32, scikit-learn usually uses double floats, this parameter ensures that every array of double floats is converted into single floats

  • runtime – string, defined the runtime to use as described in OnnxInference.

  • target_opset – targetted ONNX opset

  • conv_options – conversion options, see to_onnx

  • nopython – used by numba jitter

Attributes created by method fit:

  • estimator_: cloned and trained version of estimator

  • onnxrt_: objet of type OnnxInference,

    sklearn.preprocessing.FunctionTransformer

  • numpy_code_: python code equivalent to the inference

    method if the runtime is ‘numpy’ or ‘numba’

  • onnx_io_names_: dictionary, additional information

    if the runtime is ‘numpy’ or ‘numba’

New in version 0.7.

source on GitHub

__init__(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#
assert_almost_equal(X, **kwargs)#

Checks that ONNX and scikit-learn produces the same outputs.

source on GitHub

fit(X, y, sample_weight=None)#

Trains based estimator.

source on GitHub

predict(X)#

Transforms with ONNX.

Parameters:

X – features

Returns:

transformed features

source on GitHub

predict_proba(X)#

Transforms with ONNX.

Parameters:

X – features

Returns:

transformed features

source on GitHub

raw_predict(X)#

Transforms with scikit-learn.

Parameters:

X – features

Returns:

transformed features

source on GitHub

raw_predict_proba(X)#

Transforms with scikit-learn.

Parameters:

X – features

Returns:

transformed features

source on GitHub

class mlprodict.sklapi.onnx_speed_up.OnnxSpeedupCluster(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#

Bases: ClusterMixin, _OnnxPipelineStepSpeedup

Trains with scikit-learn, transform with ONNX.

Parameters:
  • estimator – estimator to train

  • enforce_float32 – boolean onnxruntime only supports float32, scikit-learn usually uses double floats, this parameter ensures that every array of double floats is converted into single floats

  • runtime – string, defined the runtime to use as described in OnnxInference.

  • target_opset – targetted ONNX opset

  • conv_options – conversion options, see to_onnx

  • nopython – used by numba jitter

Attributes created by method fit:

  • estimator_: cloned and trained version of estimator

  • onnxrt_: objet of type OnnxInference,

    sklearn.preprocessing.FunctionTransformer

  • numpy_code_: python code equivalent to the inference

    method if the runtime is ‘numpy’ or ‘numba’

  • onnx_io_names_: dictionary, additional information

    if the runtime is ‘numpy’ or ‘numba’

New in version 0.7.

source on GitHub

__init__(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#
assert_almost_equal(X, **kwargs)#

Checks that ONNX and scikit-learn produces the same outputs.

source on GitHub

fit(X, y, sample_weight=None)#

Trains based estimator.

source on GitHub

predict(X)#

Transforms with ONNX.

Parameters:

X – features

Returns:

transformed features

source on GitHub

raw_predict(X)#

Transforms with scikit-learn.

Parameters:

X – features

Returns:

transformed features

source on GitHub

raw_transform(X)#

Transforms with scikit-learn.

Parameters:

X – features

Returns:

transformed features

source on GitHub

transform(X)#

Transforms with ONNX.

Parameters:

X – features

Returns:

transformed features

source on GitHub

class mlprodict.sklapi.onnx_speed_up.OnnxSpeedupRegressor(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#

Bases: RegressorMixin, _OnnxPipelineStepSpeedup

Trains with scikit-learn, transform with ONNX.

Parameters:
  • estimator – estimator to train

  • enforce_float32 – boolean onnxruntime only supports float32, scikit-learn usually uses double floats, this parameter ensures that every array of double floats is converted into single floats

  • runtime – string, defined the runtime to use as described in OnnxInference.

  • target_opset – targetted ONNX opset

  • conv_options – conversion options, see to_onnx

  • nopython – used by numba jitter

Attributes created by method fit:

  • estimator_: cloned and trained version of estimator

  • onnxrt_: objet of type OnnxInference,

    sklearn.preprocessing.FunctionTransformer

  • numpy_code_: python code equivalent to the inference

    method if the runtime is ‘numpy’ or ‘numba’

  • onnx_io_names_: dictionary, additional information

    if the runtime is ‘numpy’ or ‘numba’

New in version 0.7.

source on GitHub

__init__(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#
assert_almost_equal(X, **kwargs)#

Checks that ONNX and scikit-learn produces the same outputs.

source on GitHub

fit(X, y, sample_weight=None)#

Trains based estimator.

source on GitHub

predict(X)#

Transforms with ONNX.

Parameters:

X – features

Returns:

transformed features

source on GitHub

raw_predict(X)#

Transforms with scikit-learn.

Parameters:

X – features

Returns:

transformed features

source on GitHub

class mlprodict.sklapi.onnx_speed_up.OnnxSpeedupTransformer(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#

Bases: TransformerMixin, _OnnxPipelineStepSpeedup

Trains with scikit-learn, transform with ONNX.

Parameters:
  • estimator – estimator to train

  • enforce_float32 – boolean onnxruntime only supports float32, scikit-learn usually uses double floats, this parameter ensures that every array of double floats is converted into single floats

  • runtime – string, defined the runtime to use as described in OnnxInference.

  • target_opset – targetted ONNX opset

  • conv_options – conversion options, see to_onnx

  • nopython – used by numba jitter

Attributes created by method fit:

  • estimator_: cloned and trained version of estimator

  • onnxrt_: objet of type OnnxInference,

    sklearn.preprocessing.FunctionTransformer

  • numpy_code_: python code equivalent to the inference

    method if the runtime is ‘numpy’ or ‘numba’

  • onnx_io_names_: dictionary, additional information

    if the runtime is ‘numpy’ or ‘numba’

New in version 0.7.

source on GitHub

__init__(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#
_sklearn_auto_wrap_output_keys = {'transform'}#
assert_almost_equal(X, **kwargs)#

Checks that ONNX and scikit-learn produces the same outputs.

source on GitHub

fit(X, y=None, sample_weight=None)#

Trains based estimator.

source on GitHub

raw_transform(X)#

Transforms with scikit-learn.

Parameters:

X – features

Returns:

transformed features

source on GitHub

transform(X)#

Transforms with ONNX.

Parameters:

X – features

Returns:

transformed features

source on GitHub

class mlprodict.sklapi.onnx_speed_up._OnnxPipelineStepSpeedup(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#

Bases: BaseEstimator, OnnxOperatorMixin

Speeds up inference by replacing methods transform or predict by a runtime for ONNX.

Parameters:
  • estimator – estimator to train

  • enforce_float32 – boolean onnxruntime only supports float32, scikit-learn usually uses double floats, this parameter ensures that every array of double floats is converted into single floats

  • runtime – string, defined the runtime to use as described in OnnxInference.

  • target_opset – targetted ONNX opset

  • conv_options – options for conversions, see to_onnx

  • nopython – used by numba jitter

Attributes created by method fit:

  • estimator_: cloned and trained version of estimator

  • onnxrt_: objet of type OnnxInference,

    sklearn.preprocessing.FunctionTransformer

  • numpy_code_: python code equivalent to the inference

    method if the runtime is ‘numpy’ or ‘numba’

  • onnx_io_names_: dictionary, additional information

    if the runtime is ‘numpy’ or ‘numba’

New in version 0.7.

source on GitHub

__getstate__()#

pickle does not support functions. This method removes any link to function when the runtime is ‘numpy’.

source on GitHub

__init__(estimator, runtime='python', enforce_float32=True, target_opset=None, conv_options=None, nopython=True)#
__setstate__(state)#

pickle does not support functions. This method restores the function created when the runtime is ‘numpy’.

source on GitHub

_build_onnx_runtime(onx)#

Returns an instance of OnnxTransformer which executes the ONNX graph.

Parameters:
  • onx – ONNX graph

  • runtime – runtime type (see OnnxInference)

Returns:

instance of OnnxInference

source on GitHub

_build_onnx_runtime_numpy(onx)#

Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically compiles it with method _build_onnx_runtime_numpy_compile().

source on GitHub

_build_onnx_runtime_numpy_compile(opsets)#

Second part of _build_onnx_runtime_numpy().

source on GitHub

_check_fitted_()#
_to_onnx(fitted_estimator, inputs)#

Converts an estimator inference into ONNX.

Parameters:
  • estimator – any estimator following scikit-learn API

  • inputs – example of inputs

Returns:

ONNX

source on GitHub

fit(X, y=None, sample_weight=None, **kwargs)#

Fits the estimator, converts to ONNX.

Parameters:
  • X – features

  • args – other arguments

  • kwargs – fitting options

source on GitHub

onnx_converter()#

Returns a converter for this transform.

source on GitHub

onnx_parser()#

Returns a parser for this model.

source on GitHub

onnx_shape_calculator()#

Returns a shape calculator for this transform.

source on GitHub

property op_version#

Returns the opset version.

source on GitHub