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; null for hard classifiers and regressors.
explanations - the prediction explanations; null if 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 Details

    • Prediction

      public Prediction(Number output)
      Constructs a prediction without probability estimates or explanations.
      Parameters:
      output - the predicted value.
    • Prediction

      public Prediction(Number output, double[] probabilities)
      Constructs a prediction with optional probability estimates and no explanations.
      Parameters:
      output - the predicted value.
      probabilities - posteriori class probabilities.
    • Prediction

      public Prediction(Number output, double[] probabilities, Explanations explanations)
      Creates an instance of a Prediction record class.
      Parameters:
      output - the value for the output record component
      probabilities - the value for the probabilities record component
      explanations - the value for the explanations record component
  • Method Details

    • toJson

      public String toJson()
      Serializes this prediction to a JSON string.
      Returns:
      the JSON string representation.
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • output

      public Number output()
      Returns the value of the output record component.
      Returns:
      the value of the output record component
    • probabilities

      public double[] probabilities()
      Returns the value of the probabilities record component.
      Returns:
      the value of the probabilities record component
    • explanations

      public Explanations explanations()
      Returns the value of the explanations record component.
      Returns:
      the value of the explanations record component