public class NominalPrediction extends java.lang.Object implements Prediction, java.io.Serializable, RevisionHandler
MISSING_VALUE
Constructor and Description |
---|
NominalPrediction(double actual,
double[] distribution)
Creates the NominalPrediction object with a default weight of 1.0.
|
NominalPrediction(double actual,
double[] distribution,
double weight)
Creates the NominalPrediction object.
|
Modifier and Type | Method and Description |
---|---|
double |
actual()
Gets the actual class value.
|
double[] |
distribution()
Gets the predicted probabilities
|
java.lang.String |
getRevision()
Returns the revision string.
|
static double[] |
makeDistribution(double predictedClass,
int numClasses)
Convert a single prediction into a probability distribution
with all zero probabilities except the predicted value which
has probability 1.0.
|
static double[] |
makeUniformDistribution(int numClasses)
Creates a uniform probability distribution -- where each of the
possible classes is assigned equal probability.
|
double |
margin()
Calculates the prediction margin.
|
double |
predicted()
Gets the predicted class value.
|
java.lang.String |
toString()
Gets a human readable representation of this prediction.
|
double |
weight()
Gets the weight assigned to this prediction.
|
public NominalPrediction(double actual, double[] distribution)
actual
- the actual value, or MISSING_VALUE.distribution
- the predicted probability distribution. Use
NominalPrediction.makeDistribution() if you only know the predicted value.public NominalPrediction(double actual, double[] distribution, double weight)
actual
- the actual value, or MISSING_VALUE.distribution
- the predicted probability distribution. Use
NominalPrediction.makeDistribution() if you only know the predicted value.weight
- the weight assigned to the prediction.public double[] distribution()
public double actual()
actual
in interface Prediction
public double predicted()
predicted
in interface Prediction
public double weight()
weight
in interface Prediction
public double margin()
public static double[] makeDistribution(double predictedClass, int numClasses)
predictedClass
- the index of the predicted class, or
MISSING_VALUE if no prediction was made.numClasses
- the number of possible classes for this nominal
prediction.public static double[] makeUniformDistribution(int numClasses)
numClasses
- the number of possible classes for this nominal
prediction.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRevision()
getRevision
in interface RevisionHandler