Record Class Prediction
java.lang.Object
java.lang.Record
smile.model.Prediction
- Record Components:
output- the predicted value (class label, cluster label, prototype index/grid cell, anomaly flag, or regression output).probabilities- posteriori class probabilities for soft classifiers;nullfor hard classifiers, regressors, clustering, vector quantization, and anomaly detection models.centroid- cluster centroid or prototype code vector coordinates;nullfor classifiers, regressors, and anomaly detection models.error- quantization error (distance to prototype) for vector quantization models;nullotherwise.score- anomaly or decision score for anomaly detection models;nullotherwise.explanations- the prediction explanations;nullif not requested.
- All Implemented Interfaces:
Serializable
public record Prediction(Object output, double[] probabilities, double[] centroid, Double error, Double score, Explanations explanations)
extends Record
implements Serializable
The model prediction containing the predicted output value, optional class
probability estimates for soft classification models, optional cluster/prototype
centroid coordinates for clustering and vector quantization models, optional
quantization error, optional anomaly score, and optional explanations.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPrediction(Boolean anomaly, Double score, Explanations explanations) Constructs an anomaly detection prediction with anomaly flag, score, and optional explanations.Prediction(Number output) Constructs a prediction without probability estimates or explanations.Prediction(Number output, double[] probabilities) Constructs a prediction with optional probability estimates and no explanations.Prediction(Number output, double[] probabilities, double[] centroid, Explanations explanations) Constructs a prediction with optional probability estimates, centroid, and explanations.Prediction(Number output, double[] probabilities, Explanations explanations) Constructs a prediction with optional probability estimates and explanations.Prediction(Object output, double[] probabilities, double[] centroid, Double error, Double score, Explanations explanations) Creates an instance of aPredictionrecord class.Prediction(Object output, double[] probabilities, double[] centroid, Double error, Explanations explanations) Constructs a prediction with optional probability estimates, centroid, error, and explanations. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]centroid()Returns the value of thecentroidrecord component.final booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorrecord component.Returns the value of theexplanationsrecord component.final inthashCode()Returns a hash code value for this object.output()Returns the value of theoutputrecord component.double[]Returns the value of theprobabilitiesrecord component.score()Returns the value of thescorerecord component.toJson()Serializes this prediction to a JSON string.toString()Returns a string representation of this record class.
-
Constructor Details
-
Prediction
Constructs a prediction without probability estimates or explanations.- Parameters:
output- the predicted value.
-
Prediction
Constructs a prediction with optional probability estimates and no explanations.- Parameters:
output- the predicted value.probabilities- posteriori class probabilities.
-
Prediction
Constructs a prediction with optional probability estimates and explanations.- Parameters:
output- the predicted value.probabilities- posteriori class probabilities.explanations- the prediction explanations.
-
Prediction
public Prediction(Number output, double[] probabilities, double[] centroid, Explanations explanations) Constructs a prediction with optional probability estimates, centroid, and explanations.- Parameters:
output- the predicted value.probabilities- posteriori class probabilities.centroid- cluster centroid coordinates.explanations- the prediction explanations.
-
Prediction
public Prediction(Object output, double[] probabilities, double[] centroid, Double error, Explanations explanations) Constructs a prediction with optional probability estimates, centroid, error, and explanations.- Parameters:
output- the predicted value.probabilities- posteriori class probabilities.centroid- cluster or prototype centroid coordinates.error- quantization error.explanations- the prediction explanations.
-
Prediction
Constructs an anomaly detection prediction with anomaly flag, score, and optional explanations.- Parameters:
anomaly- the anomaly flag (truefor anomaly,falsefor normal).score- the anomaly or decision score.explanations- the prediction explanations.
-
Prediction
public Prediction(Object output, double[] probabilities, double[] centroid, Double error, Double score, Explanations explanations) Creates an instance of aPredictionrecord class.- Parameters:
output- the value for theoutputrecord componentprobabilities- the value for theprobabilitiesrecord componentcentroid- the value for thecentroidrecord componenterror- the value for theerrorrecord componentscore- the value for thescorerecord componentexplanations- the value for theexplanationsrecord component
-
-
Method Details
-
toJson
Serializes this prediction to a JSON string.- Returns:
- the JSON string representation.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
output
-
probabilities
public double[] probabilities()Returns the value of theprobabilitiesrecord component.- Returns:
- the value of the
probabilitiesrecord component
-
centroid
-
error
-
score
-
explanations
Returns the value of theexplanationsrecord component.- Returns:
- the value of the
explanationsrecord component
-