- java.lang.Object
-
- com.pervasive.datarush.operators.AbstractLogicalOperator
-
- com.pervasive.datarush.operators.StreamingOperator
-
- com.pervasive.datarush.operators.ExecutableOperator
-
- com.pervasive.datarush.analytics.util.AbstractPredictor
-
- com.pervasive.datarush.analytics.svm.predictor.SVMPredictor
-
- All Implemented Interfaces:
LogicalOperator
public final class SVMPredictor extends AbstractPredictor
Operator responsible for classification based on a SVM PMML model. This supports eitherCSVC
SVMs orone-class
SVMs. We distinguish the two cases by the presence ofPMMLModelSpec.getTargetCols()
. If there are zero target columns, it is assumed to be aone-class
SVM. Otherwise, there must be exactly of column of typeTokenTypeConstant.STRING
, in which case it is aCSVC
SVM.For
CSVC
SVMs, the PMML is expected to containSupportVectorMachine
's withSupportVectorMachine#getTargetCategory()
andSupportVectorMachine#getAlternateTargetCategory()
populated. Each of the SVM's are evaluated, adding a "vote" to either target category or alternate target category. The predicted value is that receiving the most votes.For
one-class
SVMs, target category and alternate target category will be ignored. The result will either be "-1" if theSupportVectorMachine
evaluated to a number less that zero or "1" if greater than zero.NOTE: this operator is non-parallel
-
-
Field Summary
Fields Modifier and Type Field Description static String
FIELD_WINNER
Constant for the winner field.
-
Constructor Summary
Constructors Constructor Description SVMPredictor()
Creates a newSVMPredictor
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
computeMetadata(StreamingMetadataContext ctx)
Default implementation of computeMetadata.protected void
execute(PMMLModel pmml, RecordValued input, ScalarSettable[] predictedFields)
Called to perform prediction.protected RecordTokenType
predictedType(PMMLModelSpec modelSpec)
Given the model spec, returns the predicted type.-
Methods inherited from class com.pervasive.datarush.analytics.util.AbstractPredictor
execute, getInput, getModel, getOutput, pushPrediction, stepNext
-
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
-
-
-
-
Field Detail
-
FIELD_WINNER
public static final String FIELD_WINNER
Constant for the winner field.- See Also:
- Constant Field Values
-
-
Method Detail
-
computeMetadata
protected void computeMetadata(StreamingMetadataContext ctx)
Description copied from class:AbstractPredictor
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
- Overrides:
computeMetadata
in classAbstractPredictor
- Parameters:
ctx
- the context
- Output type is set to input type plus
-
predictedType
protected RecordTokenType predictedType(PMMLModelSpec modelSpec)
Description copied from class:AbstractPredictor
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 )- Specified by:
predictedType
in classAbstractPredictor
- Parameters:
modelSpec
- the model metadata- Returns:
- the predicted type
-
execute
protected void execute(PMMLModel pmml, RecordValued input, ScalarSettable[] predictedFields)
Description copied from class:AbstractPredictor
Called to perform prediction. Subclasses are expected to loop over the input by callingAbstractPredictor.stepNext()
. For each row of input, subclasses should first set the predicted values in thepredictedFields
array and then invokeAbstractPredictor.pushPrediction()
. Subclasses should not invokepushEndOfData
since that is automatically handled by the base class.- Specified by:
execute
in classAbstractPredictor
- Parameters:
pmml
- 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 byAbstractPredictor.predictedType(PMMLModelSpec)
.
-
-