module npy.onnx_sklearn_wrapper
#
Short summary#
module mlprodict.npy.onnx_sklearn_wrapper
Helpers to use numpy API to easily write converters for scikit-learn classes for onnx.
Functions#
function |
truncated documentation |
---|---|
Default converter for a classifier with one input and two outputs, label and probabilities of the same input type. … |
|
Default converter for a clustering with one input and two outputs, label and distances of the same input type. It … |
|
Default converter for a regressor with one input and one output of the same type. It assumes instance operator … |
|
Default converter for a transformer with one input and one output of the same type. It assumes instance operator … |
|
Default shape calculator for a classifier with one input and two outputs, label (int64) and probabilites of the same … |
|
Default shape calculator for a clustering with one input and two outputs, label (int64) and distances of the same type. … |
|
Default shape calculator for a regressor with one input and one output of the same type. |
|
Default shape calculator for a transformer with one input and one output of the same type. |
|
Adds ONNX graph to skl2onnx container and scope. |
|
Decorator to declare a converter for a class derivated from scikit-learn, implementing inference method … |
|
Decorator to declare a converter for a classifier implemented using numpy syntax but executed with ONNX … |
|
Decorator to declare a converter for a cluster implemented using numpy syntax but executed with ONNX … |
|
Decorator to declare a converter for a regressor implemented using numpy syntax but executed with ONNX … |
|
Decorator to declare a converter for a transformer implemented using numpy syntax but executed with ONNX … |
|
Registers or updates a converter for a new model so that it can be converted when inserted in a scikit-learn pipeline. … |
Documentation#
Helpers to use numpy API to easily write converters for scikit-learn classes for onnx.
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._call_validate(self, X)#
- mlprodict.npy.onnx_sklearn_wrapper._common_converter_begin(scope, operator, container, n_outputs)#
- mlprodict.npy.onnx_sklearn_wrapper._common_converter_int_t(scope, operator, container)#
- mlprodict.npy.onnx_sklearn_wrapper._common_converter_t(scope, operator, container)#
- mlprodict.npy.onnx_sklearn_wrapper._common_shape_calculator_int_t(operator)#
- mlprodict.npy.onnx_sklearn_wrapper._common_shape_calculator_t(operator)#
- mlprodict.npy.onnx_sklearn_wrapper._converter_classifier(scope, operator, container)#
Default converter for a classifier with one input and two outputs, label and probabilities of the same input type. It assumes instance operator has an attribute onnx_numpy_fct_ from a function wrapped with decorator
onnxsklearn_classifier
.New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._converter_cluster(scope, operator, container)#
Default converter for a clustering with one input and two outputs, label and distances of the same input type. It assumes instance operator has an attribute onnx_numpy_fct_ from a function wrapped with decorator
onnxsklearn_cluster
.New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._converter_regressor(scope, operator, container)#
Default converter for a regressor with one input and one output of the same type. It assumes instance operator has an attribute onnx_numpy_fct_ from a function wrapped with decorator
onnxsklearn_regressor
.New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._converter_transformer(scope, operator, container)#
Default converter for a transformer with one input and one output of the same type. It assumes instance operator has an attribute onnx_numpy_fct_ from a function wrapped with decorator
onnxsklearn_transformer
.New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._internal_decorator(fct, op_version=None, runtime=None, signature=None, register_class=None, overwrite=True, options=None)#
- mlprodict.npy.onnx_sklearn_wrapper._internal_method_decorator(register_class, method, op_version=None, runtime=None, signature=None, method_names=None, overwrite=True, options=None)#
- mlprodict.npy.onnx_sklearn_wrapper._shape_calculator_classifier(operator)#
Default shape calculator for a classifier with one input and two outputs, label (int64) and probabilites of the same type.
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._shape_calculator_cluster(operator)#
Default shape calculator for a clustering with one input and two outputs, label (int64) and distances of the same type.
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._shape_calculator_regressor(operator)#
Default shape calculator for a regressor with one input and one output of the same type.
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._shape_calculator_transformer(operator)#
Default shape calculator for a transformer with one input and one output of the same type.
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper._skl2onnx_add_to_container(onx, scope, container, outputs)#
Adds ONNX graph to skl2onnx container and scope.
- Parameters:
onx – onnx graph
scope – scope
container – container
- mlprodict.npy.onnx_sklearn_wrapper.onnxsklearn_class(method_name, op_version=None, runtime=None, signature=None, method_names=None, overwrite=True)#
Decorator to declare a converter for a class derivated from scikit-learn, implementing inference method and using numpy syntax but executed with ONNX operators.
- Parameters:
method_name – name of the method implementing the inference method with numpy API for ONNX
op_version – ONNX opset version
runtime – ‘onnxruntime’ or one implemented by
OnnxInference
signature – if None, the signature is replaced by a standard signature depending on the model kind, otherwise, it is the signature of the ONNX function
method_names – if None, method names is guessed based on the class kind (transformer, regressor, classifier, clusterer)
overwrite – overwrite existing registered function if any
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper.onnxsklearn_classifier(op_version=None, runtime=None, signature=None, register_class=None, overwrite=True)#
Decorator to declare a converter for a classifier implemented using numpy syntax but executed with ONNX operators.
- Parameters:
op_version – ONNX opset version
runtime – ‘onnxruntime’ or one implemented by
OnnxInference
signature – if None, the signature is replaced by a standard signature for transformer
NDArraySameType("all")
register_class – automatically register this converter for this class to sklearn-onnx
overwrite – overwrite existing registered function if any
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper.onnxsklearn_cluster(op_version=None, runtime=None, signature=None, register_class=None, overwrite=True)#
Decorator to declare a converter for a cluster implemented using numpy syntax but executed with ONNX operators.
- Parameters:
op_version – ONNX opset version
runtime – ‘onnxruntime’ or one implemented by
OnnxInference
signature – if None, the signature is replaced by a standard signature for transformer
NDArraySameType("all")
register_class – automatically register this converter for this class to sklearn-onnx
overwrite – overwrite existing registered function if any
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper.onnxsklearn_regressor(op_version=None, runtime=None, signature=None, register_class=None, overwrite=True)#
Decorator to declare a converter for a regressor implemented using numpy syntax but executed with ONNX operators.
- Parameters:
op_version – ONNX opset version
runtime – ‘onnxruntime’ or one implemented by
OnnxInference
signature – if None, the signature is replaced by a standard signature for transformer
NDArraySameType("all")
register_class – automatically register this converter for this class to sklearn-onnx
overwrite – overwrite existing registered function if any
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper.onnxsklearn_transformer(op_version=None, runtime=None, signature=None, register_class=None, overwrite=True)#
Decorator to declare a converter for a transformer implemented using numpy syntax but executed with ONNX operators.
- Parameters:
op_version – ONNX opset version
runtime – ‘onnxruntime’ or one implemented by
OnnxInference
signature – if None, the signature is replaced by a standard signature for transformer
NDArraySameType("all")
register_class – automatically register this converter for this class to sklearn-onnx
overwrite – overwrite existing registered function if any
New in version 0.6.
- mlprodict.npy.onnx_sklearn_wrapper.update_registered_converter_npy(model, alias, convert_fct, shape_fct=None, overwrite=True, parser=None, options=None)#
Registers or updates a converter for a new model so that it can be converted when inserted in a scikit-learn pipeline. This function assumes the converter is written as a function decoarated with
onnxsklearn_transformer
.- Parameters:
model – model class
alias – alias used to register the model
shape_fct – function which checks or modifies the expected outputs, this function should be fast so that the whole graph can be computed followed by the conversion of each model, parallelized or not
convert_fct – function which converts a model
overwrite – False to raise exception if a converter already exists
parser – overwrites the parser as well if not empty
options – registered options for this converter
The alias is usually the library name followed by the model name.
New in version 0.6.