How to use the skl2onnx.common._registration.register_shape_calculator function in skl2onnx

To help you get started, we’ve selected a few skl2onnx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onnx / sklearn-onnx / skl2onnx / shape_calculators / linear_classifier.py View on Github external
# license information.
# --------------------------------------------------------------------------

from ..common._registration import register_shape_calculator
from ..common.shape_calculator import calculate_linear_classifier_output_shapes


register_shape_calculator('SklearnLinearClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnLinearSVC',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnAdaBoostClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnBaggingClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnDecisionTreeClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnRandomForestClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnExtraTreeClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnExtraTreesClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnGradientBoostingClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnBernoulliNB',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnComplementNB',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnGaussianNB',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnMultinomialNB',
github onnx / sklearn-onnx / skl2onnx / shape_calculators / concat.py View on Github external
nt = i.type.__class__.__name__
        if len(seen_types) == 0:
            seen_types.append(nt)
        elif nt != seen_types[0]:
            inps = "\n".join(str(v) for v in operator.inputs)
            outs = "\n".join(str(v) for v in operator.outputs)
            raise RuntimeError(
                "Columns must have the same type. "
                "C++ backends do not support mixed types.\n"
                "Inputs:\n{}\nOutputs:\n{}".format(
                    inps, outs))
    operator.outputs[0].type.shape = [N, C]


register_shape_calculator('SklearnConcat', calculate_sklearn_concat)
register_shape_calculator('SklearnGenericUnivariateSelect',
                          calculate_sklearn_concat)
register_shape_calculator('SklearnMultiply', calculate_sklearn_concat)
register_shape_calculator('SklearnRFE', calculate_sklearn_concat)
register_shape_calculator('SklearnRFECV', calculate_sklearn_concat)
register_shape_calculator('SklearnSelectFdr', calculate_sklearn_concat)
register_shape_calculator('SklearnSelectFpr', calculate_sklearn_concat)
register_shape_calculator('SklearnSelectFromModel', calculate_sklearn_concat)
register_shape_calculator('SklearnSelectFwe', calculate_sklearn_concat)
register_shape_calculator('SklearnSelectKBest', calculate_sklearn_concat)
register_shape_calculator('SklearnSelectPercentile', calculate_sklearn_concat)
register_shape_calculator('SklearnVarianceThreshold', calculate_sklearn_concat)
github onnx / sklearn-onnx / skl2onnx / shape_calculators / scaler.py View on Github external
N = operator.inputs[0].type.shape[0]
    C = 0
    for variable in operator.inputs:
        if isinstance(variable.type.shape[1], numbers.Integral):
            C += variable.type.shape[1]
        else:
            C = None
            break

    operator.outputs[0].type.shape = [N, C]


register_shape_calculator('SklearnRobustScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnNormalizer',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnMinMaxScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnMaxAbsScaler',
                          calculate_sklearn_scaler_output_shapes)
github onnx / sklearn-onnx / skl2onnx / shape_calculators / linear_regressor.py View on Github external
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

from ..common._registration import register_shape_calculator
from ..common.shape_calculator import calculate_linear_regressor_output_shapes


register_shape_calculator('SklearnAdaBoostRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnBaggingRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnLinearRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnLinearSVR',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnDecisionTreeRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnRandomForestRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnExtraTreeRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnExtraTreesRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnGradientBoostingRegressor',
github onnx / sklearn-onnx / skl2onnx / shape_calculators / polynomial_features.py View on Github external
from ..common.utils import check_input_and_output_types


def calculate_sklearn_polynomial_features(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(
        operator, good_input_types=[
            FloatTensorType, Int64TensorType, DoubleTensorType])

    N = operator.inputs[0].type.shape[0]
    model = operator.raw_operator
    operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
    operator.outputs[0].type.shape = [N, model.n_output_features_]


register_shape_calculator('SklearnPolynomialFeatures',
                          calculate_sklearn_polynomial_features)
github onnx / sklearn-onnx / skl2onnx / shape_calculators / scaler.py View on Github external
else:
            C = None
            break

    operator.outputs[0].type.shape = [N, C]


register_shape_calculator('SklearnRobustScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnNormalizer',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnMinMaxScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnMaxAbsScaler',
                          calculate_sklearn_scaler_output_shapes)
github onnx / sklearn-onnx / skl2onnx / shape_calculators / scaler.py View on Github external
> 1):
            raise RuntimeError('Batch size must be identical across inputs.')

    N = operator.inputs[0].type.shape[0]
    C = 0
    for variable in operator.inputs:
        if isinstance(variable.type.shape[1], numbers.Integral):
            C += variable.type.shape[1]
        else:
            C = None
            break

    operator.outputs[0].type.shape = [N, C]


register_shape_calculator('SklearnRobustScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnNormalizer',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnMinMaxScaler',
                          calculate_sklearn_scaler_output_shapes)
register_shape_calculator('SklearnMaxAbsScaler',
                          calculate_sklearn_scaler_output_shapes)
github onnx / sklearn-onnx / skl2onnx / shape_calculators / linear_regressor.py View on Github external
from ..common.shape_calculator import calculate_linear_regressor_output_shapes


register_shape_calculator('SklearnAdaBoostRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnBaggingRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnLinearRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnLinearSVR',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnDecisionTreeRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnRandomForestRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnExtraTreeRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnExtraTreesRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnGradientBoostingRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnKNeighborsRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnMLPRegressor',
                          calculate_linear_regressor_output_shapes)
register_shape_calculator('SklearnRANSACRegressor',
                          calculate_linear_regressor_output_shapes)
github onnx / sklearn-onnx / skl2onnx / _supported_operators.py View on Github external
::

        from onnxmltools.convert.common.shape_calculator import calculate_linear_classifier_output_shapes
        from skl2onnx.operator_converters.RandomForest import convert_sklearn_random_forest_classifier
        from skl2onnx import update_registered_converter
        update_registered_converter(SGDClassifier, 'SklearnLinearClassifier',
                                    calculate_linear_classifier_output_shapes,
                                    convert_sklearn_random_forest_classifier)
    """ # noqa
    if (not overwrite and model in sklearn_operator_name_map
            and alias != sklearn_operator_name_map[model]):
        warnings.warn("Model '{0}' was already registered under alias "
                      "'{1}'.".format(model, sklearn_operator_name_map[model]))
    sklearn_operator_name_map[model] = alias
    register_converter(alias, convert_fct, overwrite=overwrite)
    register_shape_calculator(alias, shape_fct, overwrite=overwrite)
    if parser is not None:
        from ._parse import update_registered_parser
        update_registered_parser(model, parser)
github onnx / sklearn-onnx / skl2onnx / shape_calculators / linear_classifier.py View on Github external
from ..common._registration import register_shape_calculator
from ..common.shape_calculator import calculate_linear_classifier_output_shapes


register_shape_calculator('SklearnLinearClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnLinearSVC',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnAdaBoostClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnBaggingClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnDecisionTreeClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnRandomForestClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnExtraTreeClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnExtraTreesClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnGradientBoostingClassifier',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnBernoulliNB',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnComplementNB',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnGaussianNB',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnMultinomialNB',
                          calculate_linear_classifier_output_shapes)
register_shape_calculator('SklearnKNeighborsClassifier',