id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
6,531
import pickle import os import numpy as np import shutil import torch import warnings import hummingbird from hummingbird.ml._utils import pandas_installed, get_device, from_strings_to_ints, dump_versions, check_dumped_versions from hummingbird.ml.operator_converters import constants from hummingbird.ml.containers._skl...
This function contains the code to enable predictions over torchscript models. It is used to translates inputs in the proper torch format.
6,532
from copy import deepcopy import psutil import numpy as np from .operator_converters import constants from ._parse import parse_sklearn_api_model, parse_onnx_api_model, parse_sparkml_api_model from ._topology import convert as topology_converter from ._utils import ( assert_torch_installed, assert_lightgbm_inst...
This function converts the specified input *model* into an implementation targeting *backend*. *Convert* supports [Sklearn], [LightGBM], [XGBoost], [ONNX], and [SparkML] models. For *LightGBM* and *XGBoost* currently only the Sklearn API is supported. The detailed list of models and backends can be found at `hummingbir...
6,533
from copy import deepcopy import psutil import numpy as np from .operator_converters import constants from ._parse import parse_sklearn_api_model, parse_onnx_api_model, parse_sparkml_api_model from ._topology import convert as topology_converter from ._utils import ( assert_torch_installed, assert_lightgbm_inst...
A convert function for batch by batch prediction use cases. For some backends such as TVM, a container returned by `convert(...)` function above has a strict requirement on the allowable input shape. The container returned by this function is more flexible in that it can predict on the input of size `test_input.shape[0...
6,534
import numpy as np from onnxconverter_common.registration import register_converter from . import constants from ._gbdt_commons import convert_gbdt_classifier_common, convert_gbdt_common from ._tree_commons import TreeParameters def _get_tree_parameters(tree_info, extra_config): """ Parse the tree and returns a...
Converter for `xgboost.XGBClassifier` (trained using the Sklearn API). Args: operator: An operator wrapping a `xgboost.XGBClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch ...
6,535
import numpy as np from onnxconverter_common.registration import register_converter from . import constants from ._gbdt_commons import convert_gbdt_classifier_common, convert_gbdt_common from ._tree_commons import TreeParameters def _get_tree_parameters(tree_info, extra_config): """ Parse the tree and returns a...
Converter for `xgboost.XGBRegressor` (trained using the Sklearn API). Args: operator: An operator wrapping a `xgboost.XGBRegressor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch mo...
6,536
import torch import torch.nn from ._physical_operator import PhysicalOperator def _compute_log_det_cholesky(matrix_chol, covariance_type, n_features): if covariance_type == "full": n_components, _, _ = matrix_chol.shape log_det_chol = torch.sum(torch.log(matrix_chol.reshape(n_components, -1)[:, :: n...
null
6,537
import torch import torch.nn from ._physical_operator import PhysicalOperator def _compute_precision_cholesky(covariances, covariance_type): estimate_precision_error_message = ( "Fitting the mixture model failed because some components have " "ill-defined empirical covariance (for instance caused b...
null
6,538
import numpy as np import torch from datetime import datetime from onnxconverter_common.registration import register_converter from ._physical_operator import PhysicalOperator from . import constants class Prophet(PhysicalOperator, torch.nn.Module): """ Class implementing Prophet operator in PyTorch. """ ...
Converter for `prophet.Prophet` Args: operator: An operator wrapping a `prophet.Prophet` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,539
import numpy as np from onnxconverter_common.registration import register_converter from .._sv_implementations import SVC class SVC(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, kernel, degree, sv, nv, a, b, gamma, coef0, classes, device): super(SVC, self).__init__(logical_operat...
Converter for `ai.onnx.ml.SVMClassifier` Args: operator: An operator wrapping a `ai.onnx.ml.SVMClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,540
from onnxconverter_common.registration import register_converter from .. import constants from .._pipeline_implementations import Concat class Concat(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator): super(Concat, self).__init__(logical_operator, transformer=True) def forward(s...
Converter for `ai.onnx.ml.FeatureVectorizer. Args: operator: An operator wrapping a `ai.onnx.ml.FeatureVectorizer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,541
import numpy as np from onnxconverter_common.registration import register_converter from .._scaler_implementations import Scaler class Scaler(PhysicalOperator, torch.nn.Module): """ Class implementing Scaler operators in PyTorch. Supported normalizers are L1, L2 and Max. """ def __init__(self, logical...
Converter for `ai.onnx.ml.Scaler` Args: operator: An operator wrapping a `ai.onnx.ml.Scaler` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,542
from onnxconverter_common.registration import register_converter from .._discretizer_implementations import Binarizer class Binarizer(PhysicalOperator, torch.nn.Module): """ Class implementing Binarizer operators in PyTorch. """ def __init__(self, logical_operator, threshold, device): super(Bi...
Converter for `ai.onnx.ml.Binarizer` Args: operator: An operator wrapping a `ai.onnx.ml.Binarizer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,543
from onnxconverter_common.registration import register_converter from .._normalizer_implementations import Normalizer class Normalizer(PhysicalOperator, torch.nn.Module): """ Class implementing Normalizer operators in PyTorch. Supported normalizers are L1, L2 and Max. """ def __init__(self, logical_op...
Converter for `ai.onnx.ml.Normalizer` Args: operator: An operator wrapping a `ai.onnx.ml.Normalizer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,544
import numpy as np from onnxconverter_common.registration import register_converter from .._imputer_implementations import SimpleImputer class SimpleImputer(PhysicalOperator, torch.nn.Module): """ Class implementing SimpleImputer operators in PyTorch. """ def __init__(self, logical_operator, device, s...
Converter for `ai.onnx.ml.Imputer` Args: operator: An operator wrapping a `ai.onnx.ml.Imputer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,545
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._gbdt_commons import convert_gbdt_classifier_common, convert_gbdt_common from .._tree_commons import TreeParameters, convert_decision_ensemble_tree_common, get_parameters_for_tree_trav_common def _dummy_g...
Converter for `ai.onnx.ml.TreeEnsembleClassifier`. Args: operator: An operator wrapping a `ai.onnx.ml.TreeEnsembleClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,546
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._gbdt_commons import convert_gbdt_classifier_common, convert_gbdt_common from .._tree_commons import TreeParameters, convert_decision_ensemble_tree_common, get_parameters_for_tree_trav_common def _dummy_g...
Converter for `ai.onnx.ml.TreeEnsembleRegressor`. Args: operator: An operator wrapping a `ai.onnx.ml.TreeEnsembleRegressor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,547
import numpy as np from onnxconverter_common.registration import register_converter from .._label_encoder_implementations import NumericLabelEncoder, StringLabelEncoder class StringLabelEncoder(PhysicalOperator, torch.nn.Module): """ LabelEncoder over string data types. When the ONNX backend is selected, t...
Converter for `ai.onnx.ml.LabelEncoder` Args: operator: An operator wrapping a `ai.onnx.ml.LabelEncoder` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,548
import numpy as np from onnxconverter_common.registration import register_converter from .._one_hot_encoder_implementations import OneHotEncoderString, OneHotEncoder class OneHotEncoderString(PhysicalOperator, torch.nn.Module): """ Class implementing OneHotEncoder operators for strings in PyTorch. Because...
Converter for `ai.onnx.ml.OneHotEncoder` Args: operator: An operator wrapping a `ai.onnx.ml.OneHotEncoder` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,549
from onnxconverter_common.registration import register_converter from .. import constants from .._array_feature_extractor_implementations import ArrayFeatureExtractor class ArrayFeatureExtractor(PhysicalOperator, torch.nn.Module): """ Class implementing ArrayFeatureExtractor in PyTorch This is used by Sel...
Converter for `ai.onnx.ml.ArrayFeatureExtractor`. Args: operator: An operator wrapping a `ai.onnx.ml.ArrayFeatureExtractor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,550
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Cast(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, to_type): ...
Converter for `ai.onnx.Cast`. Args: operator: An operator wrapping a `ai.onnx.Cast` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,551
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Concat(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator): s...
Converter for `ai.onnx.Concat`. Args: operator: An operator wrapping a `ai.onnx.Concat` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,552
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Reshape(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, shape): ...
Converter for `ai.onnx.Reshape`. Args: operator: An operator wrapping a `ai.onnx.Reshape` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,553
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class ArgMax(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, axis): ...
Converter for `ai.onnx.ArgMax`. Args: operator: An operator wrapping a `ai.onnx.ArgMax` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,554
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Sum(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator): super...
Converter for `ai.onnx.Sum`. Args: operator: An operator wrapping a `ai.onnx.Sum` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,555
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Add(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, val): ...
Converter for `ai.onnx.Add`. Args: operator: An operator wrapping a `ai.onnx.Add` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,556
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Sub(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, val): ...
Converter for `ai.onnx.Sub`. Args: operator: An operator wrapping a `ai.onnx.Sub` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,557
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Neg(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator): super...
Converter for `ai.onnx.Neg`. Args: operator: An operator wrapping a `ai.onnx.Neg` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,558
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Abs(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator): super...
Converter for `ai.onnx.Abs`. Args: operator: An operator wrapping a `ai.onnx.Abs` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,559
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Mul(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, val): ...
Converter for `ai.onnx.Mul`. Args: operator: An operator wrapping a `ai.onnx.Mul` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,560
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class MatMul(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, val): ...
Converter for `ai.onnx.MatMul`. Args: operator: An operator wrapping a `ai.onnx.MatMul` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,561
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Div(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, val): ...
Converter for `ai.onnx.Div`. Args: operator: An operator wrapping a `ai.onnx.Div` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,562
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Less(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, val): ...
Converter for `ai.onnx.Less`. Args: operator: An operator wrapping a `ai.onnx.Less` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,563
import numpy as np from onnxconverter_common.registration import register_converter from .._linear_implementations import LinearModel class LinearModel(PhysicalOperator, torch.nn.Module): def __init__( self, logical_operator, coefficients, intercepts, device, classes...
Converter for `ai.onnx.ml.LinearClassifier`. Args: operator: An operator wrapping a `ai.onnx.ml.LinearClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,564
import numpy as np from onnxconverter_common.registration import register_converter from .._linear_implementations import LinearModel class LinearModel(PhysicalOperator, torch.nn.Module): def __init__( self, logical_operator, coefficients, intercepts, device, classes...
Converter for `ai.onnx.ml.LinearRegression` Args: operator: An operator wrapping a `ai.onnx.ml.LinearRegression` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,565
import numpy as np from onnxconverter_common.registration import register_converter from . import constants from ._gbdt_commons import convert_gbdt_classifier_common, convert_gbdt_common from ._tree_commons import TreeParameters def _get_tree_parameters(tree_info, extra_config): """ Parse the tree and returns a...
Converter for `lightgbm.LGBMClassifier` (trained using the Sklearn API). Args: operator: An operator wrapping a `lightgbm.LGBMClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTo...
6,566
import numpy as np from onnxconverter_common.registration import register_converter from . import constants from ._gbdt_commons import convert_gbdt_classifier_common, convert_gbdt_common from ._tree_commons import TreeParameters def _get_tree_parameters(tree_info, extra_config): """ Parse the tree and returns a...
Converter for `lightgbm.LGBMRegressor` and `lightgbm.LGBMRanker` (trained using the Sklearn API). Args: operator: An operator wrapping a `lightgbm.LGBMRegressor` or `lightgbm.LGBMRanker` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to se...
6,567
import numpy as np from onnxconverter_common.registration import register_converter from . import constants from ._gbdt_commons import convert_gbdt_classifier_common, convert_gbdt_common from ._tree_commons import TreeParameters def _get_tree_parameters(tree_info, extra_config): """ Parse the tree and returns a...
Converter for `lightgbm.Booster` Args: operator: An operator wrapping a `lightgbm.Booster` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,568
import torch import numpy as np from onnxconverter_common.topology import Variable from onnxconverter_common.registration import register_converter from .._physical_operator import PhysicalOperator from .._discretizer_implementations import Binarizer, KBinsDiscretizer class KBinsDiscretizer(PhysicalOperator, torch.nn....
Converter for `pyspark.ml.feature.Bucketizer` Args: operator: An operator wrapping a `pyspark.ml.feature.QuantileDiscretizer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,569
import torch import numpy as np from onnxconverter_common.topology import Variable from onnxconverter_common.registration import register_converter from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Concat(PhysicalOperator, torch.nn.Module): def __init__(self, lo...
Converter for `pyspark.ml.feature.VectorAssembler` Args: operator: An operator wrapping a `pyspark.ml.feature.VectorAssembler` device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,570
import numpy as np from onnxconverter_common.registration import register_converter from .._linear_implementations import LinearModel class LinearModel(PhysicalOperator, torch.nn.Module): def __init__( self, logical_operator, coefficients, intercepts, device, classes...
Converter for `pyspark.ml.classification.LogisticRegressionModel` Args: operator: An operator wrapping a `pyspark.ml.classification.LogisticRegressionModel` device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Re...
6,571
from onnxconverter_common.registration import register_converter from .._sv_implementations import SVC class SVC(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, kernel, degree, sv, nv, a, b, gamma, coef0, classes, device): super(SVC, self).__init__(logical_operator, classification=...
Converter for `sklearn.svm.SVC` and `sklearn.svm.NuSVC` Args: operator: An operator wrapping a `sklearn.svm.SVC` or `sklearn.svm.NuSVC` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorc...
6,572
import numpy as np from onnxconverter_common.registration import register_converter from .._mlp_implementations import MLPModel, MLPClassificationModel class MLPClassificationModel(MLPModel): def __init__(self, logical_operator, weights, biases, activation, classes, device): super(MLPClassificationModel, s...
Converter for `sklearn.neural_network.MLPClassifier` Args: operator: An operator wrapping a `sklearn.neural_network.MLPClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch mod...
6,573
import numpy as np from onnxconverter_common.registration import register_converter from .._mlp_implementations import MLPModel, MLPClassificationModel class MLPModel(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, weights, biases, activation, device): super(MLPModel, self).__init_...
Converter for `sklearn.neural_network.MLPRegressor` Args: operator: An operator wrapping a `sklearn.neural_network.MLPRegressor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,574
from .._physical_operator import PhysicalOperator from onnxconverter_common.registration import register_converter import torch import itertools class PolynomialFeatures(PhysicalOperator, torch.nn.Module): """ Class implementing PolynomialFeatures operators in PyTorch. # TODO extend this class to support hi...
Converter for `sklearn.preprocessing.PolynomialFeatures` Currently this supports only degree 2, and does not support interaction_only Args: operator: An operator wrapping a `sklearn.preprocessing.PolynomialFeatures` model device: String defining the type of device the converted operator should be run on extra_config: E...
6,575
from packaging.version import Version, parse import numpy as np from onnxconverter_common.registration import register_converter import torch from .._physical_operator import PhysicalOperator class Bagging(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, is_classifier, n_estimators, classes)...
null
6,576
import numpy as np from onnxconverter_common.registration import register_converter from .._scaler_implementations import Scaler class Scaler(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, offset, scale, device): def forward(self, x): def convert_sklearn_robust_scaler(operator, dev...
null
6,577
import numpy as np from onnxconverter_common.registration import register_converter from .._scaler_implementations import Scaler class Scaler(PhysicalOperator, torch.nn.Module): """ Class implementing Scaler operators in PyTorch. Supported normalizers are L1, L2 and Max. """ def __init__(self, logical...
null
6,578
import numpy as np from onnxconverter_common.registration import register_converter from .._scaler_implementations import Scaler class Scaler(PhysicalOperator, torch.nn.Module): """ Class implementing Scaler operators in PyTorch. Supported normalizers are L1, L2 and Max. """ def __init__(self, logical...
null
6,579
import numpy as np from onnxconverter_common.registration import register_converter from .._scaler_implementations import Scaler class Scaler(PhysicalOperator, torch.nn.Module): """ Class implementing Scaler operators in PyTorch. Supported normalizers are L1, L2 and Max. """ def __init__(self, logical...
null
6,580
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._gbdt_commons import convert_gbdt_common, convert_gbdt_classifier_common from .._tree_commons import get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn, TreeParameters def _get_n_feat...
Converter for `sklearn.ensemble.GradientBoostingClassifier` Args: operator: An operator wrapping a `sklearn.ensemble.GradientBoostingClassifier` or `sklearn.ensemble.HistGradientBoostingClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration...
6,581
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._gbdt_commons import convert_gbdt_common, convert_gbdt_classifier_common from .._tree_commons import get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn, TreeParameters def _get_n_feat...
Converter for `sklearn.ensemble.GradientBoostingRegressor`. Args: operator: An operator wrapping a `sklearn.ensemble.GradientBoostingRegressor` or `sklearn.ensemble.HistGradientBoostingRegressor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration u...
6,582
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._gbdt_commons import convert_gbdt_common, convert_gbdt_classifier_common from .._tree_commons import get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn, TreeParameters def _get_n_feat...
Converter for `sklearn.ensemble.HistGradientBoostingClassifier` Args: operator: An operator wrapping a `sklearn.ensemble.HistGradientBoostingClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy ...
6,583
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._gbdt_commons import convert_gbdt_common, convert_gbdt_classifier_common from .._tree_commons import get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn, TreeParameters def _get_n_feat...
Converter for `sklearn.ensemble.HistGradientBoostingRegressor` Args: operator: An operator wrapping a `sklearn.ensemble.HistGradientBoostingRegressor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Re...
6,584
from onnxconverter_common.registration import register_converter from .._normalizer_implementations import Normalizer class Normalizer(PhysicalOperator, torch.nn.Module): """ Class implementing Normalizer operators in PyTorch. Supported normalizers are L1, L2 and Max. """ def __init__(self, logical_op...
Converter for `sklearn.preprocessing.Normalizer` Args: operator: An operator wrapping a `sklearn.preprocessing.Normalizer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,585
import numpy as np from onnxconverter_common.registration import register_converter from .._mixture_implementations import BayesianGaussianMixture class BayesianGaussianMixture(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, weight_concentration_prior_type, ...
Converter for `sklearn.mixture.BayesianGaussianMixture` Args: operator: An operator wrapping a `sklearn.mixture.BayesianGaussianMixture` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTor...
6,586
import copy from onnxconverter_common.registration import register_converter from .. import constants from .._tree_commons import get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn from .._tree_commons import convert_decision_ensemble_tree_common def convert_sklearn_random_forest_classifier(operato...
Converter for `sklearn.tree.DecisionTreeClassifier`. Args: operator: An operator wrapping a `sklearn.tree.DecisionTreeClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch mode...
6,587
import copy from onnxconverter_common.registration import register_converter from .. import constants from .._tree_commons import get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn from .._tree_commons import convert_decision_ensemble_tree_common def convert_sklearn_random_forest_regressor(operator...
Converter for `sklearn.tree.DecisionTreeRegressor`. Args: operator: An operator wrapping a `sklearn.tree.DecisionTreeRegressor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,588
from .._physical_operator import PhysicalOperator import numpy as np from onnxconverter_common.registration import register_converter import torch from .._imputer_implementations import SimpleImputer, MissingIndicator class SimpleImputer(PhysicalOperator, torch.nn.Module): """ Class implementing SimpleImputer ...
Converter for `sklearn.impute.SimpleImputer` Args: operator: An operator wrapping a `sklearn.impute.SimpleImputer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,589
from .._physical_operator import PhysicalOperator import numpy as np from onnxconverter_common.registration import register_converter import torch from .._imputer_implementations import SimpleImputer, MissingIndicator class MissingIndicator(PhysicalOperator, torch.nn.Module): """ Class implementing Imputer ope...
Converter for `sklearn.impute.MissingIndicator` Args: operator: An operator wrapping a `sklearn.impute.MissingIndicator` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,590
import torch import numpy as np from onnxconverter_common.registration import register_converter from .._physical_operator import PhysicalOperator from .._discretizer_implementations import Binarizer, KBinsDiscretizer class Binarizer(PhysicalOperator, torch.nn.Module): """ Class implementing Binarizer operator...
Converter for `sklearn.preprocessing.Binarizer` Args: operator: An operator wrapping a `sklearn.preprocessing.Binarizer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,591
import torch import numpy as np from onnxconverter_common.registration import register_converter from .._physical_operator import PhysicalOperator from .._discretizer_implementations import Binarizer, KBinsDiscretizer class KBinsDiscretizer(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, e...
Converter for `sklearn.preprocessing.KBinsDiscretizer` Args: operator: An operator wrapping a `sklearn.preprocessing.KBinsDiscretizer` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch...
6,592
import torch from .._physical_operator import PhysicalOperator from onnxconverter_common.registration import register_converter class KMeans(PhysicalOperator, torch.nn.Module): """ Class implementing Kmeans in PyTorch """ def __init__(self, logical_operator, centroids, device): super(KMeans, sel...
null
6,593
import numpy as np from onnxconverter_common.registration import register_converter from .._label_encoder_implementations import NumericLabelEncoder, StringLabelEncoder class StringLabelEncoder(PhysicalOperator, torch.nn.Module): """ LabelEncoder over string data types. When the ONNX backend is selected, t...
Converter for `sklearn.preprocessing.LabelEncoder` Args: operator: An operator wrapping a `sklearn.preprocessing.LabelEncoder` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,594
import numpy as np from onnxconverter_common.registration import register_converter from .._nb_implementations import BernoulliNBModel, GaussianNBModel class BernoulliNBModel(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, classes, binarize, jll_calc_bias, feature_log_prob_minus_neg_prob, ...
Converter for `sklearn.naive_bayes.BernoulliNB` Args: operator: An operator wrapping a `sklearn.naive_bayes.BernoulliNB` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,595
import numpy as np from onnxconverter_common.registration import register_converter from .._nb_implementations import BernoulliNBModel, GaussianNBModel class BernoulliNBModel(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, classes, binarize, jll_calc_bias, feature_log_prob_minus_neg_prob, ...
Converter for `sklearn.naive_bayes.MultinomialNB` Args: operator: An operator wrapping a `sklearn.naive_bayes.MultinomialNB` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,596
import numpy as np from onnxconverter_common.registration import register_converter from .._nb_implementations import BernoulliNBModel, GaussianNBModel class GaussianNBModel(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, classes, jll_calc_bias, theta, sigma, device): super(Gaussia...
Converter for `sklearn.naive_bayes.GaussianNB` Args: operator: An operator wrapping a `sklearn.naive_bayes.GaussianNB` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,597
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._array_feature_extractor_implementations import ArrayFeatureExtractor from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class ArrayFeatureExtra...
Converter for ArrayFeatureExtractor. Args: operator: An operator wrapping a ArrayFeatureExtractor operator device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,598
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._array_feature_extractor_implementations import ArrayFeatureExtractor from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Concat(PhysicalOp...
Converter for concat operators injected when parsing Sklearn pipelines. Args: operator: An empty operator device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,599
import numpy as np from onnxconverter_common.registration import register_converter import torch from .. import constants from .._array_feature_extractor_implementations import ArrayFeatureExtractor from .._physical_operator import PhysicalOperator from .._pipeline_implementations import Concat class Multiply(PhysicalO...
Converter for multiply operators injected when parsing Sklearn pipelines. Args: operator: An empty operator device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,600
import numpy as np from onnxconverter_common.registration import register_converter from .._decomposition_implementations import KernelPCA, Decomposition, CrossDecomposition class Decomposition(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, mean, transform_matrix, device): super(D...
Converter for `sklearn.decomposition.PCA` Args: operator: An operator wrapping a `sklearn.decomposition.PCA` transformer device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,601
import numpy as np from onnxconverter_common.registration import register_converter from .._decomposition_implementations import KernelPCA, Decomposition, CrossDecomposition class KernelPCA(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, kernel, degree, sv, scaled_alphas, gamma, coef0, k_f...
Converter for `sklearn.decomposition.KernelPCA` Args: operator: An operator wrapping a `sklearn.decomposition.KernelPCA` transformer device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,602
import numpy as np from onnxconverter_common.registration import register_converter from .._decomposition_implementations import KernelPCA, Decomposition, CrossDecomposition class Decomposition(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, mean, transform_matrix, device): super(D...
Converter for `sklearn.decomposition.FastICA` Args: operator: An operator wrapping a `sklearn.decomposition.FastICA` transformer device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,603
import numpy as np from onnxconverter_common.registration import register_converter from .._decomposition_implementations import KernelPCA, Decomposition, CrossDecomposition class Decomposition(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, mean, transform_matrix, device): super(D...
Converter for `sklearn.decomposition.TruncatedSVD` Args: operator: An operator wrapping a `sklearn.decomposition.TruncatedSVD` transformer device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch m...
6,604
import numpy as np from onnxconverter_common.registration import register_converter from .._decomposition_implementations import KernelPCA, Decomposition, CrossDecomposition class CrossDecomposition(PhysicalOperator, torch.nn.Module): def __init__(self, logical_operator, x_mean, x_std, y_mean, coefficients, device...
Converter for `sklearn.cross_decomposition.PLSRegression` Args: operator: An operator wrapping a `sklearn.cross_decomposition.PLSRegression` transformer device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Return...
6,605
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._one_hot_encoder_implementations import OneHotEncoderString, OneHotEncoder class OneHotEncoderString(PhysicalOperator, torch.nn.Module): """ Class implementing OneHotEncoder operators for strings...
Converter for `sklearn.preprocessing.OneHotEncoder` Args: operator: An operator wrapping a `sklearn.preprocessing.OneHotEncoder` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,606
import numpy as np from onnxconverter_common.registration import register_converter from .. import constants from .._tree_commons import ( get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn, get_tree_params_and_type, get_parameters_for_gemm_common, ) from .._tree_implementations imp...
Converter for `sklearn.ensemble.IsolationForest`. Args: operator: An operator wrapping a tree (ensemble) isolation forest model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch model
6,607
import numpy as np from onnxconverter_common.registration import register_converter from hummingbird.ml.operator_converters._kneighbors_implementations import KNeighborsModel, MetricType from hummingbird.ml.operator_converters import constants def _convert_kneighbors_model(operator, device, extra_config, is_classifier)...
Converter for `sklearn.neighbors.KNeighborsRegressor` Args: operator: An operator wrapping a `sklearn.neighbors.KNeighborsRegressor` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch m...
6,608
import numpy as np from onnxconverter_common.registration import register_converter from hummingbird.ml.operator_converters._kneighbors_implementations import KNeighborsModel, MetricType from hummingbird.ml.operator_converters import constants def _convert_kneighbors_model(operator, device, extra_config, is_classifier)...
Converter for `sklearn.neighbors.KNeighborsClassifier` Args: operator: An operator wrapping a `sklearn.neighbors.KNeighborsClassifier` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch...
6,609
import numpy as np from onnxconverter_common.registration import register_converter from .._array_feature_extractor_implementations import ArrayFeatureExtractor class ArrayFeatureExtractor(PhysicalOperator, torch.nn.Module): """ Class implementing ArrayFeatureExtractor in PyTorch This is used by SelectKBe...
Converter for `sklearn.feature_selection.SelectKBest`. Args: operator: An operator wrapping a `sklearn.feature_selection.SelectKBest` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: A PyTorch ...
6,610
import numpy as np from onnxconverter_common.registration import register_converter from .._array_feature_extractor_implementations import ArrayFeatureExtractor class ArrayFeatureExtractor(PhysicalOperator, torch.nn.Module): """ Class implementing ArrayFeatureExtractor in PyTorch This is used by SelectKBe...
Converter for `sklearn.feature_selection.VarianceThreshold`. Args: operator: An operator wrapping a `sklearn.feature_selection.VarianceThreshold` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns...
6,611
import numpy as np from onnxconverter_common.registration import register_converter from .._array_feature_extractor_implementations import ArrayFeatureExtractor class ArrayFeatureExtractor(PhysicalOperator, torch.nn.Module): """ Class implementing ArrayFeatureExtractor in PyTorch This is used by SelectKBe...
Converter for `sklearn.feature_selection.SelectPercentile`. Args: operator: An operator wrapping a `sklearn.feature_selection.SelectPercentile` model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy Returns: ...
6,612
import numpy as np from onnxconverter_common.registration import register_converter from sklearn._loss.link import LogLink from .._linear_implementations import LinearModel class LinearModel(PhysicalOperator, torch.nn.Module): def __init__( self, logical_operator, coefficients, inte...
Converter for `sklearn.svm.LinearSVC`, `sklearn.linear_model.LogisticRegression`, `sklearn.linear_model.SGDClassifier`, and `sklearn.linear_model.LogisticRegressionCV` Args: operator: An operator wrapping a `sklearn.svm.LinearSVC`, `sklearn.linear_model.LogisticRegression`, `sklearn.linear_model.SGDClassifier`, or `skl...
6,613
import numpy as np from onnxconverter_common.registration import register_converter from sklearn._loss.link import LogLink from .._linear_implementations import LinearModel class LinearModel(PhysicalOperator, torch.nn.Module): def __init__( self, logical_operator, coefficients, inte...
Converter for `sklearn.linear_model.LinearRegression`, `sklearn.linear_model.Lasso`, `sklearn.linear_model.ElasticNet`, `sklearn.linear_model.Ridge`, `sklearn.svm.LinearSVR` and `sklearn.linear_model.RidgeCV` Args: operator: An operator wrapping a `sklearn.linear_model.LinearRegression`, `sklearn.svm.LinearSVR` or `skl...
6,614
from collections import OrderedDict from copy import deepcopy import pprint from uuid import uuid4 import numpy as np from onnxconverter_common.optimizer import LinkedNode, _topological_sort from sklearn import pipeline from sklearn.compose import ColumnTransformer from sklearn.ensemble import BaggingClassifier, Baggin...
null
6,615
from collections import OrderedDict from copy import deepcopy import pprint from uuid import uuid4 import numpy as np from onnxconverter_common.optimizer import LinkedNode, _topological_sort from sklearn import pipeline from sklearn.compose import ColumnTransformer from sklearn.ensemble import BaggingClassifier, Baggin...
null
6,616
import numpy as np import os from packaging.version import Version, parse import torch from uuid import uuid4 from onnxconverter_common.registration import get_converter from onnxconverter_common.topology import Topology as ONNXTopology import onnx from hummingbird.ml.containers import ( PyTorchSklearnContainerRegr...
This function is used to convert a `Topology` object into a *backend* model. Args: topology: The `Topology` object that will be converted into a backend model backend: Which backend the model should be run on test_input: Inputs for PyTorch model tracing device: Which device the translated model will be run on extra_con...
6,617
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) def sklearn_installed(): """ ...
Put all supported Sklearn operators on a list.
6,618
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) def sparkml_installed(): """ ...
List all supported SparkML operators.
6,619
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) def xgboost_installed(): """ ...
List all supported XGBoost (Sklearn API) operators.
6,620
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) def lightgbm_installed(): """ ...
List all supported LightGBM (Sklearn API) operators.
6,621
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) def onnx_runtime_installed(): ...
List all supported ONNXML operators.
6,622
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) def prophet_installed(): """ ...
List all supported Prophet (Sklearn API) operators.
6,623
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) backends = _build_backend_map() de...
The set of supported backends is defined here.
6,624
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) sklearn_operator_list = _build_skle...
Associate Sklearn with the operator class names. If two scikit-learn (API) models share a single name, it means they are equivalent in terms of conversion.
6,625
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) onnxml_operator_list = _build_onnxm...
Associate ONNXML with the operator class names. If two ONNXML models share a single name, it means they are equivalent in terms of conversion.
6,626
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) sparkml_operator_list = _build_spar...
Associate Spark-ML with the operator class names. If two Spark-ML models share a single name, it means they are equivalent in terms of conversion.
6,627
from collections import defaultdict from .exceptions import MissingConverter from ._utils import ( torch_installed, sklearn_installed, lightgbm_installed, xgboost_installed, onnx_runtime_installed, tvm_installed, sparkml_installed, prophet_installed, ) prophet_operator_list = _build_prop...
Associate Prophet with the operator class names.
6,628
import re from docutils import nodes, utils from sphinx.util.nodes import split_explicit_title def format_commit_text(sha): return sha[:7]
null
6,629
import re from docutils import nodes, utils from sphinx.util.nodes import split_explicit_title __version__ = "1.2.0" def user_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Sphinx role for linking to a user profile. Defaults to linking to Github profiles, but the profile URIS can be ...
null
6,630
from operator import attrgetter import inspect import subprocess import os import sys from functools import partial def _get_git_revision(): try: revision = subprocess.check_output(REVISION_CMD.split()).strip() except (subprocess.CalledProcessError, OSError): print("Failed to execute git to get ...
Returns a linkcode_resolve function for the given URL format revision is a git commit reference (hash or name) package is the name of the root module of the package url_fmt is along the lines of ('https://github.com/USER/PROJECT/' 'blob/{revision}/{package}/' '{path}#L{lineno}')