models.pipeline

Pipeline utils for this package.

Module Contents

Classes

Pipeline(self,input_features,output_features) A pipeline model that exposes a sequence of models as a single model,
PipelineRegressor(self,input_features,output_features) A pipeline model that exposes a sequence of models as a single model,
PipelineClassifier(self,input_features,class_labels,output_features=None) A pipeline model that exposes a sequence of models as a single model,
class Pipeline(input_features, output_features)

A pipeline model that exposes a sequence of models as a single model, It requires a set of inputs, a sequence of other models and a set of outputs.

This class is the base class for PipelineClassifier and PipelineRegressor, which contain a sequence ending in a classifier or regressor and themselves behave like a classifier or regressor. This class may be used directly for a sequence of feature transformer objects.

__init__(input_features, output_features)

Create a pipeline of models to be executed sequentially.

input_features: [list of 2-tuples]
Name(s) of the input features, given as a list of (‘name’, datatype) tuples. The datatypes entry can be any of the data types defined in the models.datatypes module.
output_features: [list of features]
Name(s) of the output features, given as a list of (‘name’,datatype) tuples. The datatypes entry can be any of the data types defined in the models.datatypes module. All features must be either defined in the inputs or be produced by one of the contained models.
add_model(spec)

Add a protobuf spec or models.MLModel instance to the pipeline.

All input features of this model must either match the input_features of the pipeline, or match the outputs of a previous model.

spec: [MLModel, Model_pb2]
A protobuf spec or MLModel instance containing a model.
class PipelineRegressor(input_features, output_features)

A pipeline model that exposes a sequence of models as a single model, It requires a set of inputs, a sequence of other models and a set of outputs. In this case the pipeline itself behaves as a regression model by designating a real valued output feature as its ‘predicted feature’.

__init__(input_features, output_features)

Create a set of pipeline models given a set of model specs. The final output model must be a regression model.

input_features: [list of 2-tuples]
Name(s) of the input features, given as a list of (‘name’, datatype) tuples. The datatypes entry can be any of the data types defined in the models.datatypes module.
output_features: [list of features]
Name(s) of the output features, given as a list of (‘name’,datatype) tuples. The datatypes entry can be any of the data types defined in the models.datatypes module. All features must be either defined in the inputs or be produced by one of the contained models.
add_model(spec)

Add a protobuf spec or models.MLModel instance to the pipeline.

All input features of this model must either match the input_features of the pipeline, or match the outputs of a previous model.

spec: [MLModel, Model_pb2]
A protobuf spec or MLModel instance containing a model.
class PipelineClassifier(input_features, class_labels, output_features=None)

A pipeline model that exposes a sequence of models as a single model, It requires a set of inputs, a sequence of other models and a set of outputs. In this case the pipeline itself behaves as a classification model by designating a discrete categorical output feature as its ‘predicted feature’.

__init__(input_features, class_labels, output_features=None)

Create a set of pipeline models given a set of model specs. The last model in this list must be a classifier model.

input_features: [list of 2-tuples]
Name(s) of the input features, given as a list of (‘name’, datatype) tuples. The datatypes entry can be any of the data types defined in the models.datatypes module.
class_labels: [list]
A list of string or integer class labels to use in making predictions. This list must match the class labels in the model outputting the categorical predictedFeatureName
output_features: [list]
A string or a list of two strings specifying the names of the two output features, the first being a class label corresponding to the class with the highest predicted score, and the second being a dictionary mapping each class to its score. If output_features is a string, it specifies the predicted class label and the class scores is set to the default value of “classProbability.”
add_model(spec)

Add a protobuf spec or models.MLModel instance to the pipeline.

All input features of this model must either match the input_features of the pipeline, or match the outputs of a previous model.

spec: [MLModel, Model_pb2]
A protobuf spec or MLModel instance containing a model.