hummingbird.ml._parse¶
All functions used for parsing input models are listed here. Some code here have been copied from https://github.com/onnx/sklearn-onnx/.
- hummingbird.ml._parse._declare_input_variables(topology, raw_model_container, extra_config)[source]¶
- hummingbird.ml._parse._declare_output_variables(raw_model_container, extra_config, outputs)[source]¶
- hummingbird.ml._parse._fetch_input_slice(topology, inputs, column_indices)[source]¶
Taken from https://github.com/onnx/sklearn-onnx/blob/9939c089a467676f4ffe9f3cb91098c4841f89d8/skl2onnx/_parse.py#L53.
- hummingbird.ml._parse._get_column_index(i, inputs)[source]¶
Taken from https://github.com/onnx/sklearn-onnx/blob/9939c089a467676f4ffe9f3cb91098c4841f89d8/skl2onnx/common/utils.py#L50. Returns a tuples (variable index, column index in that variable). The function has two different behaviours, one when i (column index) is an integer, another one when i is a string (column name). If i is a string, the function looks for input name with this name and returns (index, 0). If i is an integer, let’s assume first we have two inputs I0 = FloatTensorType([None, 2]) and I1 = FloatTensorType([None, 3]), in this case, here are the results:
get_column_index(0, inputs) -> (0, 0) get_column_index(1, inputs) -> (0, 1) get_column_index(2, inputs) -> (1, 0) get_column_index(3, inputs) -> (1, 1) get_column_index(4, inputs) -> (1, 2)
- hummingbird.ml._parse._get_column_indices(indices, inputs, multiple=False)[source]¶
Taken from https://github.com/onnx/sklearn-onnx/blob/9939c089a467676f4ffe9f3cb91098c4841f89d8/skl2onnx/common/utils.py#L105. Returns the requested graph inpudes based on their indices or names. See _parse._get_column_index. Args:
indices: variables indices or names inputs: model inputs
- Returns:
a tuple (variable name, list of requested indices) if multiple is False, a dictionary { var_index: [ list of requested indices ] } if multiple is True
- hummingbird.ml._parse._parse_onnx_api(topology, model, inputs)[source]¶
This function handles all input ONNX models.
- Args:
topology: The
onnxconverter_common.topology.Topology
where the model will be added model: A ONNX model object inputs: A list of `onnxconverter_common.topology.Variable`s- Returns:
A list of output onnxconverter_common.topology.Variable which will be passed to next stage
- hummingbird.ml._parse._parse_onnx_single_operator(topology, operator)[source]¶
This function handles the parsing of all ONNX operators.
- Args:
topology: The
onnxconverter_common.topology.Topology
where the model will be added model: An ONNX operator
- hummingbird.ml._parse._parse_sklearn_api(topology, model, inputs)[source]¶
This is a delegate function adding the model to the input topology. It does nothing but invokes the correct parsing function according to the input model’s type.
- hummingbird.ml._parse._parse_sklearn_bagging(topology, model, inputs)[source]¶
Taken from https://github.com/onnx/sklearn-onnx/blob/9939c089a467676f4ffe9f3cb91098c4841f89d8/skl2onnx/_parse.py#L238. :param topology: Topology object :param model: A scikit-learn BaggingClassifier or BaggingRegressor object :param inputs: A list of Variable objects :return: A list of output variables produced by column transformer
- hummingbird.ml._parse._parse_sklearn_column_transformer(topology, model, inputs)[source]¶
Taken from https://github.com/onnx/sklearn-onnx/blob/9939c089a467676f4ffe9f3cb91098c4841f89d8/skl2onnx/_parse.py#L238. :param topology: Topology object :param model: A scikit-learn ColumnTransformer object :param inputs: A list of Variable objects :return: A list of output variables produced by column transformer
- hummingbird.ml._parse._parse_sklearn_feature_union(topology, model, inputs)[source]¶
Taken from https://github.com/onnx/sklearn-onnx/blob/9939c089a467676f4ffe9f3cb91098c4841f89d8/skl2onnx/_parse.py#L199. :param topology: Topology object :param model: A scikit-learn FeatureUnion object :param inputs: A list of Variable objects :return: A list of output variables produced by feature union
- hummingbird.ml._parse._parse_sklearn_model_selection(topology, model, inputs)[source]¶
- Parameters:
topology – Topology object
model – A sklearn.model_selection object
inputs – A list of Variable objects
- Returns:
Output produced by sklearn.model_selection.* object
- hummingbird.ml._parse._parse_sklearn_multi_output_regressor(topology, model, inputs)[source]¶
- Parameters:
topology – Topology object
model – A scikit-learn MultiOutputRegressor object
inputs – A list of Variable objects
- Returns:
Output produced by MultiOutputRegressor
- hummingbird.ml._parse._parse_sklearn_pipeline(topology, model, inputs)[source]¶
- The basic ideas of scikit-learn parsing:
Sequentially go though all stages defined in the considered scikit-learn pipeline
The output variables of one stage will be fed into its next stage as the inputs.
- Parameters:
topology – Topology object defined in _topology.py
model – scikit-learn pipeline object
inputs – A list of Variable objects
- Returns:
A list of output variables produced by the input pipeline
- hummingbird.ml._parse._parse_sklearn_regressor_chain(topology, model, inputs)[source]¶
- Parameters:
topology – Topology object
model – A scikit-learn RegressorChain object
inputs – A list of Variable objects
- Returns:
Output produced by RegressorChain
- hummingbird.ml._parse._parse_sklearn_single_model(topology, model, inputs)[source]¶
This function handles all sklearn objects composed by a single model.
- Args:
topology: The
hummingbitd.ml._topology.Topology
object where the model will be added model: A scikit-learn model object inputs: A list of `onnxconverter_common.topology.Variable`s- Returns:
A list of output onnxconverter_common.topology.Variable which will be passed to next stage
- hummingbird.ml._parse._parse_sklearn_stacking(topology, model, inputs)[source]¶
Taken from https://github.com/onnx/sklearn-onnx/blob/9939c089a467676f4ffe9f3cb91098c4841f89d8/skl2onnx/_parse.py#L238. :param topology: Topology object :param model: A scikit-learn Stacking object :param inputs: A list of Variable objects :return: A list of output variables produced by column transformer
- hummingbird.ml._parse._parse_sparkml_api(topology, model, inputs)[source]¶
This function handles all input Spark-ML models.
- Args:
topology: The
onnxconverter_common.topology.Topology
where the model will be added model: A Spark-ML model object inputs: A list of `onnxconverter_common.topology.Variable`s- Returns:
A list of output onnxconverter_common.topology.Variable which will be passed to next stage
- hummingbird.ml._parse._parse_sparkml_pipeline(topology, model, all_outputs)[source]¶
- The basic ideas of Spark-ML parsing:
Sequentially go though all stages defined in the considered Spark-ML pipeline passing all outputs that has been generated so far as the input. Operator will pick which inputs to operates on.
The output variables of one stage will be fed into its next stage as the inputs.
- Parameters:
topology – Topology object defined in _topology.py
model – Spark-ML pipeline object
all_outputs – A list of Variable objects
- Returns:
A list of output variables produced by the input pipeline
- hummingbird.ml._parse._parse_sparkml_single_operator(topology, operator, all_inputs)[source]¶
This function handles the parsing of all Spark-ML operators.
- Args:
topology: The
onnxconverter_common.topology.Topology
where the model will be added model: A Spark-ML operator all_inputs: A list of `onnxconverter_common.topology.Variable`s
- hummingbird.ml._parse._remove_zipmap(node_list)[source]¶
Method used to remove ZipMap operators in the graph.
- hummingbird.ml._parse.parse_onnx_api_model(model)[source]¶
Puts ONNX object into an abstract representation so that our framework can work seamlessly on models created with different machine learning tools.
- Args:
model: A model object in onnx format
- Returns:
A onnxconverter_common.topology.Topology object representing the input model
- hummingbird.ml._parse.parse_sklearn_api_model(model, extra_config={})[source]¶
Puts scikit-learn object into an abstract representation so that our framework can work seamlessly on models created with different machine learning tools.
- Args:
model: A model object in scikit-learn format
- Returns:
A onnxconverter_common.topology.Topology object representing the input model
- hummingbird.ml._parse.parse_sparkml_api_model(model, extra_config={})[source]¶
Puts Spark-ML object into an abstract representation so that our framework can work seamlessly on models created with different machine learning tools.
- Args:
model: A model object in Spark-ML format
- Returns:
A onnxconverter_common.topology.Topology object representing the input model