java.lang.Object
com.pervasive.datarush.operators.AbstractLogicalOperator
com.pervasive.datarush.operators.StreamingOperator
com.pervasive.datarush.operators.ExecutableOperator
com.pervasive.datarush.analytics.util.AbstractPredictor
- All Implemented Interfaces:
LogicalOperator
- Direct Known Subclasses:
ClusterPredictor,DecisionTreePredictor,LogisticRegressionPredictor,NaiveBayesPredictor,RegressionPredictor,SVMPredictor
Common base class for "predictor" processes. Predictors all take
a PMML input, a record input and produce a record output.
In addition, all predictors are parallel.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDefault implementation of computeMetadata.protected abstract voidexecute(PMMLModel model, RecordValued input, ScalarSettable[] predictedFields) Called to perform prediction.protected final voidexecute(ExecutionContext ctx) Invokesexecute(PMMLModel, RecordValued, ScalarSettable[])and performs anoutput.pushEndOfData()final RecordPortgetInput()The input data.final PMMLPortgetModel()The input for supplying the PMML modelThe original data with prediction appendedprotected abstract RecordTokenTypepredictedType(PMMLModelSpec modelSpec) Given the model spec, returns the predicted type.protected final voidPushes a prediction row consisting of input fields plus predicted fieldsprotected final booleanstepNext()Steps to the next input row, returning false at end of dataMethods inherited from class com.pervasive.datarush.operators.ExecutableOperator
cloneForExecution, getNumInputCopies, getPortSettings, handleInactiveOutputMethods inherited from class com.pervasive.datarush.operators.AbstractLogicalOperator
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
-
Constructor Details
-
AbstractPredictor
public AbstractPredictor()
-
-
Method Details
-
getInput
The input data. Any fields specified in the PMML model must be present in the input data. Additional fields will be ignored.- Returns:
- the input data
-
getModel
The input for supplying the PMML model- Returns:
- the input for the pmml model
-
getOutput
The original data with prediction appended- Returns:
- the original data with the prediction appended
-
computeMetadata
Default implementation of computeMetadata.- Output type is set to input type plus
predictedType - Input data ordering ( if ordered ) is preserved
- Input data partitioning ( if partitioned ) is preserved
- Specified by:
computeMetadatain classStreamingOperator- Parameters:
ctx- the context
- Output type is set to input type plus
-
stepNext
protected final boolean stepNext()Steps to the next input row, returning false at end of data- Returns:
- true if there is still more data
-
pushPrediction
protected final void pushPrediction()Pushes a prediction row consisting of input fields plus predicted fields -
execute
Invokesexecute(PMMLModel, RecordValued, ScalarSettable[])and performs anoutput.pushEndOfData()- Specified by:
executein classExecutableOperator- Parameters:
ctx- context in which to lookup physical ports bound to logical ports
-
predictedType
Given the model spec, returns the predicted type. This should not include the input type ( the input is automatically prepended to the type that is returned )- Parameters:
modelSpec- the model metadata- Returns:
- the predicted type
-
execute
protected abstract void execute(PMMLModel model, RecordValued input, ScalarSettable[] predictedFields) Called to perform prediction. Subclasses are expected to loop over the input by callingstepNext(). For each row of input, subclasses should first set the predicted values in thepredictedFieldsarray and then invokepushPrediction(). Subclasses should not invokepushEndOfDatasince that is automatically handled by the base class.- Parameters:
model- The input PMML modelinput- The input datapredictedFields- An array of fields that reference the predicted field locations. The array positionally corresponds to the type returned bypredictedType(PMMLModelSpec).
-