- 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
public abstract class AbstractPredictor extends ExecutableOperator
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 Constructor Description AbstractPredictor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
computeMetadata(StreamingMetadataContext ctx)
Default implementation of computeMetadata.protected abstract void
execute(PMMLModel model, RecordValued input, ScalarSettable[] predictedFields)
Called to perform prediction.protected void
execute(ExecutionContext ctx)
Invokesexecute(PMMLModel, RecordValued, ScalarSettable[])
and performs anoutput.pushEndOfData()
RecordPort
getInput()
The input data.PMMLPort
getModel()
The input for supplying the PMML modelRecordPort
getOutput()
The original data with prediction appendedprotected abstract RecordTokenType
predictedType(PMMLModelSpec modelSpec)
Given the model spec, returns the predicted type.protected void
pushPrediction()
Pushes a prediction row consisting of input fields plus predicted fieldsprotected boolean
stepNext()
Steps to the next input row, returning false at end of data-
Methods inherited from class com.pervasive.datarush.operators.ExecutableOperator
cloneForExecution, getNumInputCopies, getPortSettings, handleInactiveOutput
-
Methods inherited from class com.pervasive.datarush.operators.AbstractLogicalOperator
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
-
-
-
-
Method Detail
-
getInput
public final RecordPort 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
public final PMMLPort getModel()
The input for supplying the PMML model- Returns:
- the input for the pmml model
-
getOutput
public RecordPort getOutput()
The original data with prediction appended- Returns:
- the original data with the prediction appended
-
computeMetadata
protected void computeMetadata(StreamingMetadataContext ctx)
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:
computeMetadata
in 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
protected final void execute(ExecutionContext ctx)
Invokesexecute(PMMLModel, RecordValued, ScalarSettable[])
and performs anoutput.pushEndOfData()
- Specified by:
execute
in classExecutableOperator
- Parameters:
ctx
- context in which to lookup physical ports bound to logical ports
-
predictedType
protected abstract RecordTokenType predictedType(PMMLModelSpec modelSpec)
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 thepredictedFields
array and then invokepushPrediction()
. Subclasses should not invokepushEndOfData
since 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)
.
-
-