module sklapi.onnx_speed_up
#
Short summary#
module mlprodict.sklapi.onnx_speed_up
Speeding up scikit-learn with onnx.
Classes#
class |
truncated documentation |
---|---|
Speeds up inference by replacing methods transform or predict by a runtime for ONNX. |
|
Trains with scikit-learn, transform with ONNX. |
|
Trains with scikit-learn, transform with ONNX. |
|
Trains with scikit-learn, transform with ONNX. |
|
Trains with scikit-learn, transform with ONNX. |
Properties#
property |
truncated documentation |
---|---|
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
|
Returns the opset version. |
|
Returns the opset version. |
|
Returns the opset version. |
|
Returns the opset version. |
Returns the opset version. |
Methods#
method |
truncated documentation |
---|---|
|
pickle does not support functions. This method removes any link to function when the runtime is … |
|
pickle does not support functions. This method removes any link to function when the runtime is … |
|
pickle does not support functions. This method removes any link to function when the runtime is … |
|
pickle does not support functions. This method removes any link to function when the runtime is … |
pickle does not support functions. This method removes any link to function when the runtime is … |
|
|
pickle does not support functions. This method restores the function created when the runtime is … |
|
pickle does not support functions. This method restores the function created when the runtime is … |
|
pickle does not support functions. This method restores the function created when the runtime is … |
|
pickle does not support functions. This method restores the function created when the runtime is … |
pickle does not support functions. This method restores the function created when the runtime is … |
|
|
Returns an instance of |
|
Returns an instance of |
|
Returns an instance of |
|
Returns an instance of |
Returns an instance of |
|
|
Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically … |
|
Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically … |
|
Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically … |
|
Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically … |
Builds a runtime based on numpy. Exports the ONNX graph into python code based on numpy and then dynamically … |
|
|
Second part of |
|
Second part of |
|
Second part of |
|
Second part of |
Second part of |
|
|
|
|
|
|
|
|
|
|
Converts an estimator inference into ONNX. |
|
Converts an estimator inference into ONNX. |
|
Converts an estimator inference into ONNX. |
|
Converts an estimator inference into ONNX. |
Converts an estimator inference into ONNX. |
|
Checks that ONNX and scikit-learn produces the same outputs. |
|
Checks that ONNX and scikit-learn produces the same outputs. |
|
Checks that ONNX and scikit-learn produces the same outputs. |
|
Checks that ONNX and scikit-learn produces the same outputs. |
|
Trains based estimator. |
|
Trains based estimator. |
|
Trains based estimator. |
|
Trains based estimator. |
|
Fits the estimator, converts to ONNX. |
|
|
Returns a converter for this transform. |
|
Returns a converter for this transform. |
|
Returns a converter for this transform. |
|
Returns a converter for this transform. |
Returns a converter for this transform. |
|
|
Returns a parser for this model. |
|
Returns a parser for this model. |
|
Returns a parser for this model. |
|
Returns a parser for this model. |
Returns a parser for this model. |
|
|
Returns a shape calculator for this transform. |
|
Returns a shape calculator for this transform. |
|
Returns a shape calculator for this transform. |
|
Returns a shape calculator for this transform. |
Returns a shape calculator for this transform. |
|
Transforms with ONNX. |
|
Transforms with ONNX. |
|
Transforms with ONNX. |
|
Transforms with ONNX. |
|
Transforms with scikit-learn. |
|
Transforms with scikit-learn. |
|
Transforms with scikit-learn. |
|
Transforms with scikit-learn. |
|
Transforms with scikit-learn. |
|
Transforms with scikit-learn. |
|
Transforms with ONNX. |
|
Transforms with ONNX. |
Documentation#
Speeding up scikit-learn with onnx.
New in version 0.7.
- 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
,
- onnxrt_: objet of type
- 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.
- __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.
- fit(X, y, sample_weight=None)#
Trains based estimator.
- predict(X)#
Transforms with ONNX.
- Parameters:
X – features
- Returns:
transformed features
- predict_proba(X)#
Transforms with ONNX.
- Parameters:
X – features
- Returns:
transformed features
- raw_predict(X)#
Transforms with scikit-learn.
- Parameters:
X – features
- Returns:
transformed features
- raw_predict_proba(X)#
Transforms with scikit-learn.
- Parameters:
X – features
- Returns:
transformed features
- 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
,
- onnxrt_: objet of type
- 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.
- __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.
- fit(X, y, sample_weight=None)#
Trains based estimator.
- predict(X)#
Transforms with ONNX.
- Parameters:
X – features
- Returns:
transformed features
- raw_predict(X)#
Transforms with scikit-learn.
- Parameters:
X – features
- Returns:
transformed features
- raw_transform(X)#
Transforms with scikit-learn.
- Parameters:
X – features
- Returns:
transformed features
- transform(X)#
Transforms with ONNX.
- Parameters:
X – features
- Returns:
transformed features
- 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
,
- onnxrt_: objet of type
- 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.
- __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.
- fit(X, y, sample_weight=None)#
Trains based estimator.
- predict(X)#
Transforms with ONNX.
- Parameters:
X – features
- Returns:
transformed features
- raw_predict(X)#
Transforms with scikit-learn.
- Parameters:
X – features
- Returns:
transformed features
- 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
,
- onnxrt_: objet of type
- 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.
- __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.
- fit(X, y=None, sample_weight=None)#
Trains based estimator.
- raw_transform(X)#
Transforms with scikit-learn.
- Parameters:
X – features
- Returns:
transformed features
- transform(X)#
Transforms with ONNX.
- Parameters:
X – features
- Returns:
transformed features
- 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
,
- onnxrt_: objet of type
- 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.
- __getstate__()#
pickle does not support functions. This method removes any link to function when the runtime is ‘numpy’.
- __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’.
- _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
- _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()
.
- _build_onnx_runtime_numpy_compile(opsets)#
Second part of
_build_onnx_runtime_numpy()
.
- _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
- fit(X, y=None, sample_weight=None, **kwargs)#
Fits the estimator, converts to ONNX.
- Parameters:
X – features
args – other arguments
kwargs – fitting options
- onnx_converter()#
Returns a converter for this transform.
- onnx_parser()#
Returns a parser for this model.
- onnx_shape_calculator()#
Returns a shape calculator for this transform.
- property op_version#
Returns the opset version.