module npy.xop_convert
#
Short summary#
module mlprodict.npy.xop_convert
Easier API to build onnx graphs. Inspired from skl2onnx.
Classes#
class |
truncated documentation |
---|---|
This operator is used to call the converter of a model to insert the node coming from the conversion into a bigger … |
|
This operator is used to insert existing ONNX into the ONNX graph being built. |
Properties#
property |
truncated documentation |
---|---|
|
Returns the input names. |
Returns the input names. |
|
|
Returns self.output_names_. |
|
Returns self.output_names_. |
Static Methods#
staticmethod |
truncated documentation |
---|---|
Converts a model into ONNX and inserts it into an ONNX graph. |
|
Converts a scikit-learn model into ONNX and inserts it into an ONNX graph. The library relies on … |
Methods#
method |
truncated documentation |
---|---|
usual |
|
usual |
|
|
Adds to graph builder. |
Adds to graph builder. |
|
|
Returns the ONNX graph. |
Returns the ONNX graph. |
Documentation#
Easier API to build onnx graphs. Inspired from skl2onnx.
New in version 0.9.
- class mlprodict.npy.xop_convert.OnnxSubEstimator(model, *inputs, op_version=None, output_names=None, options=None, initial_types=None, **kwargs)#
Bases:
OnnxSubOnnx
This operator is used to call the converter of a model to insert the node coming from the conversion into a bigger ONNX graph. It supports model from scikit-learn using sklearn-onnx.
- Parameters:
model – model to convert
inputs – inputs
op_version – targetted opset
options – to rewrite the options used to convert the model
initial_types – the implementation may be wrong in guessing the input types of the model, this parameter can be used to overwrite them, usually a dictionary { input_name: numpy array as an example }
kwargs – any other parameters such as black listed or white listed operators
- __init__(model, *inputs, op_version=None, output_names=None, options=None, initial_types=None, **kwargs)#
- __repr__()#
usual
- static _to_onnx(model, inputs, op_version=None, options=None, initial_types=None, **kwargs)#
Converts a model into ONNX and inserts it into an ONNX graph.
- Parameters:
model – a trained machine learned model
inputs – inputs
op_version – opset versions or None to use the latest one
options – options to change the behaviour of the converter
kwargs – additional parameters such as black listed or while listed operators
- Returns:
ONNX model
The method currently supports models trained with scikit-learn, xgboost, :epkg`:lightgbm`.
- static _to_onnx_sklearn(model, inputs, op_version=None, options=None, initial_types=None, **kwargs)#
Converts a scikit-learn model into ONNX and inserts it into an ONNX graph. The library relies on function
to_onnx
and library :epkg:`skearn-onnx`.- Parameters:
model – a trained machine learned model
inputs – inputs
op_version – opset versions or None to use the latest one
initial_types – if None, the input types are guessed from the inputs. The function converts into ONNX the previous node of the graph and tries to infer the initial_types with the little informations it has. It may not work. It is recommended to specify this parameter.
options – options to change the behaviour of the converter
kwargs – additional parameters such as black listed or while listed operators
- Returns:
ONNX model
Default options is {‘zipmap’: False} for a classifier.
- class mlprodict.npy.xop_convert.OnnxSubOnnx(model, *inputs, output_names=None)#
Bases:
OnnxOperator
This operator is used to insert existing ONNX into the ONNX graph being built.
- __init__(model, *inputs, output_names=None)#
- __repr__()#
usual
- add_to(builder)#
Adds to graph builder.
- Parameters:
builder – instance of
_GraphBuilder
, it must have a method add_node
- property input_names#
Returns the input names.
- to_onnx_this(evaluated_inputs)#
Returns the ONNX graph.
- Parameters:
evaluated_inputs – unused
- Returns:
ONNX graph