public final class NaiveBayesPredictor extends AbstractPredictor
Laplace smoothing
in place of the "threshold" parameter.Constructor and Description |
---|
NaiveBayesPredictor()
Predicts an output based on a model and a set of training data.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeMetadata(StreamingMetadataContext ctx)
Default implementation of computeMetadata.
|
protected void |
execute(PMMLModel pmml,
RecordValued input,
ScalarSettable[] predictedFields)
Called to perform prediction.
|
double |
getLaplaceCorrector()
Returns the Laplace corrector to be used.
|
RecordPort |
getOutput()
Returns a record port consisting of the input plus predicted values appended.
|
String |
getProbabilityPrefix()
Gets the field name prefix to use for probabilities.
|
String |
getWinnerField()
Gets the name of the winner field to output.
|
boolean |
isAppendProbabilities()
Returns whether to include probabilities in the prediction.
|
boolean |
isIgnoreMissingValues()
Returns whether to ignore missing values.
|
protected RecordTokenType |
predictedType(PMMLModelSpec spec)
Given the model spec, returns the predicted type.
|
void |
setAppendProbabilities(boolean appendProbabilities)
Sets whether to include probabilities in the prediction.
|
void |
setIgnoreMissingValues(boolean ignoreMissingValues)
Sets whether to ignore missing values.
|
void |
setLaplaceCorrector(double laplaceCorrector)
Sets the Laplace corrector to be used.
|
void |
setProbabilityPrefix(String probabilityPrefix)
Sets the field name prefix to use for probabilities.
|
void |
setWinnerField(String winnerField)
Sets the name of the winner field to output.
|
execute, getInput, getModel, pushPrediction, stepNext
cloneForExecution, getNumInputCopies, getPortSettings, handleInactiveOutput
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
public NaiveBayesPredictor()
public RecordPort getOutput()
winnerField
.probabilityPrefix
.getOutput
in class AbstractPredictor
public String getWinnerField()
public void setWinnerField(String winnerField)
winnerField
- the name of the winner field to output.public String getProbabilityPrefix()
public void setProbabilityPrefix(String probabilityPrefix)
probabilityPrefix
- the field name prefix to use for probabilities.public void setIgnoreMissingValues(boolean ignoreMissingValues)
ignoreMissingValues
- whether to ignore missing valuespublic boolean isIgnoreMissingValues()
public final double getLaplaceCorrector()
NOTE: The "threshold" value specified in the PMML model will always be ignored in
favor of the Laplace corrector specified on NaiveBayesPredictor
.
public final void setLaplaceCorrector(double laplaceCorrector)
NOTE: The "threshold" value specified in the PMML model will always be ignored in
favor of the Laplace corrector specified on NaiveBayesPredictor
.
laplaceCorrector
- the Laplace corrector to be used.public boolean isAppendProbabilities()
public void setAppendProbabilities(boolean appendProbabilities)
appendProbabilities
- whether to include probabilities in the predictionprotected void computeMetadata(StreamingMetadataContext ctx)
AbstractPredictor
predictedType
computeMetadata
in class AbstractPredictor
ctx
- the contextprotected RecordTokenType predictedType(PMMLModelSpec spec)
AbstractPredictor
predictedType
in class AbstractPredictor
spec
- the model metadataprotected void execute(PMMLModel pmml, RecordValued input, ScalarSettable[] predictedFields)
AbstractPredictor
AbstractPredictor.stepNext()
. For each row of input, subclasses should first set the predicted values in
the predictedFields
array and then invoke AbstractPredictor.pushPrediction()
.
Subclasses should not invoke pushEndOfData
since that is automatically handled by
the base class.execute
in class AbstractPredictor
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 by AbstractPredictor.predictedType(PMMLModelSpec)
.Copyright © 2024 Actian Corporation. All rights reserved.