pymoose.predictors package
Contents
pymoose.predictors package#
Submodules#
- pymoose.predictors.linear_predictor module
- pymoose.predictors.multilayer_perceptron_predictor module
- pymoose.predictors.neural_network_predictor module
- pymoose.predictors.onnx_convert module
- pymoose.predictors.predictor module
- pymoose.predictors.predictor_utils module
- pymoose.predictors.tree_ensemble module
Module contents#
- class pymoose.predictors.LinearClassifier(coeffs, intercepts=None, post_transform=None)[source]#
Bases:
pymoose.predictors.linear_predictor.LinearPredictor
Linear classifier predictor interface.
- Parameters
coeffs – Array-like convertible to a (n_outputs, n_weights)-shaped ndarray.
intercepts – Optional array-like convertible to a vector.
post_transform – a PostTransform enum variant describing how to convert the raw linear model scores into probabilistic classification outputs.
- classmethod from_onnx(model_proto)[source]#
Construct LinearClassifier from a parsed ONNX model.
- Parameters
model_proto – An ONNX ModelProto containing a LinearClassifier operator node.
- Returns
A LinearClassifier with parameters and model configuration loaded from the ONNX model.
- Raises
ValueError if ONNX graph is missing expected nodes. –
RuntimeError if ONNX LinearClassifier node has an unsupported post-transform – function attribute.
- class pymoose.predictors.LinearRegressor(coeffs, intercepts=None)[source]#
Bases:
pymoose.predictors.linear_predictor.LinearPredictor
Linear regression predictor interface.
- Parameters
coeffs – Array-like convertible to a (n_outputs, n_weights)-shaped ndarray.
intercepts – Optional array-like convertible to a vector.
- classmethod from_onnx(model_proto)[source]#
Construct LinearRegressor from a parsed ONNX model.
- Parameters
model_proto – An ONNX ModelProto containing a LinearRegressor operator node.
- Returns
A LinearRegressor with weighhts and bias terms loaded from the ONNX model.
- Raises
ValueError if ONNX graph is missing expected nodes. –
- class pymoose.predictors.MLPClassifier(weights, biases, activation)[source]#
Bases:
pymoose.predictors.multilayer_perceptron_predictor.MLPPredictor
- class pymoose.predictors.MLPRegressor(weights, biases, activation)[source]#
Bases:
pymoose.predictors.multilayer_perceptron_predictor.MLPPredictor
- class pymoose.predictors.TreeEnsembleClassifier(trees, n_features, n_classes, base_score, learning_rate, transform_output, tree_class_map)[source]#
Bases:
pymoose.predictors.tree_ensemble.TreeEnsemble
Tree ensemble classification Predictor for GBTs and Random Forests.
This class can be used for binary, multiclass, or multilabel classification. Support for multiclass classification uses the one-vs-rest method.
- Parameters
trees – Nested collection of :class:`~DecisionTreeRegressor`s.
n_features – Number of features expected for input data.
n_classes – Number of output classes.
base_score – The base score for the underlying tree ensemble model, similar to a bias/intercept term.
learning_rate – Learning rate parameter used to re-scale leaf weights in the model trees.
transform_output – Boolean determining whether a softmax should be applied to derive probabilities from the tree ensemble output.
tree_class_map – Dictionary mapping
trees
indices to class indices. Keeps track of which trees intrees
correspond to each class in the one-vs-rest formulation of multiclass classification.
- classmethod from_onnx(model_proto)[source]#
Construct a TreeEnsembleClassifier from a parsed ONNX model.
- Parameters
model_proto – An ONNX ModelProto containing a TreeEnsembleClassifier node.
- Returns
A TreeEnsembleClassifier built from the parameters and configuration of the given ONNX model.
- Raises
ValueError if ONNX graph is missing expected nodes. –
- class pymoose.predictors.TreeEnsembleRegressor(trees, n_features, base_score, learning_rate)[source]#
Bases:
pymoose.predictors.tree_ensemble.TreeEnsemble
Tree ensemble regression Predictor, accommodating both GBTs and Random Forests.
- Parameters
trees – Nested collection of :class:`~DecisionTreeRegressor`s.
n_features – Number of features expected for input data.
base_score – The base score for the underlying tree ensemble model, similar to a bias/intercept term.
learning_rate – Learning rate parameter used to re-scale leaf weights in the model trees.
- classmethod from_onnx(model_proto)[source]#
Construct a TreeEnsembleRegressor from a parsed ONNX model.
- Parameters
model_proto – An ONNX ModelProto containing a TreeEnsembleRegressor node.
- Returns
A TreeEnsembleRegressor built from the parameters and configuration of the given ONNX model.
- Raises
ValueError if ONNX graph is missing expected nodes. –
- pymoose.predictors.from_onnx(model_proto)[source]#
Attempt to infer and construct a Moose predictor type from a given ONNX Model.
- Parameters
model_proto – An ONNX ModelProto containing nodes sufficient to construct some Moose predictor.
- Returns
A Moose predictor, inferred from the structure and contents of the ONNX model.
- Raises
ValueError if the Predictor type cannot be inferred, or if the ONNX graph is – malformed for the inferred Predictor type.
RuntimeError if LinearClassifier constructor throws an error due to unrecognized – post_transform attribute.