Record Class Prediction
java.lang.Object
java.lang.Record
smile.model.Prediction
- Record Components:
output- the predicted value (class label or regression output).probabilities- posteriori class probabilities for soft classifiers;nullfor hard classifiers and regressors.explanations- the prediction explanations;nullif not requested.
- All Implemented Interfaces:
Serializable
public record Prediction(Number output, double[] probabilities, Explanations explanations)
extends Record
implements Serializable
The model prediction containing the predicted output value, optional class
probability estimates for soft classification models, and optional explanations.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPrediction(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, Explanations explanations) Creates an instance of aPredictionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.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.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
Creates an instance of aPredictionrecord class.- Parameters:
output- the value for theoutputrecord componentprobabilities- the value for theprobabilitiesrecord 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
-
explanations
Returns the value of theexplanationsrecord component.- Returns:
- the value of the
explanationsrecord component
-