Record Class RegressionMetrics

java.lang.Object
java.lang.Record
smile.validation.RegressionMetrics
Record Components:
fitTime - the time in milliseconds of fitting the model.
scoreTime - the time in milliseconds of scoring the validation data.
size - the validation data size.
rss - the residual sum of squares on validation data.
mse - the mean squared error on validation data.
rmse - the root mean squared error on validation data.
mad - the mean absolute deviation on validation data.
r2 - the R-squared score on validation data.
All Implemented Interfaces:
Serializable

public record RegressionMetrics(double fitTime, double scoreTime, int size, double rss, double mse, double rmse, double mad, double r2) extends Record implements Serializable
The regression validation metrics.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    RegressionMetrics(double fitTime, double scoreTime, int size, double rss, double mse, double rmse, double mad, double r2)
    Creates an instance of a RegressionMetrics record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    double
    Returns the value of the fitTime record component.
    final int
    Returns a hash code value for this object.
    double
    mad()
    Returns the value of the mad record component.
    double
    mse()
    Returns the value of the mse record component.
    of(double fitTime, double scoreTime, double[] truth, double[] prediction)
    Computes the regression metrics.
    of(double fitTime, M model, Formula formula, DataFrame test)
    Trains and validates a model on a train/validation split.
    static <T, M extends Regression<T>>
    RegressionMetrics
    of(double fitTime, M model, T[] testx, double[] testy)
    Validates a model on a test data.
    of(M model, Formula formula, DataFrame test)
    Trains and validates a model on a train/validation split.
    static <T, M extends Regression<T>>
    RegressionMetrics
    of(M model, T[] testx, double[] testy)
    Validates a model on a test data.
    double
    r2()
    Returns the value of the r2 record component.
    double
    Returns the value of the rmse record component.
    double
    rss()
    Returns the value of the rss record component.
    double
    Returns the value of the scoreTime record component.
    int
    Returns the value of the size record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RegressionMetrics

      public RegressionMetrics(double fitTime, double scoreTime, int size, double rss, double mse, double rmse, double mad, double r2)
      Creates an instance of a RegressionMetrics record class.
      Parameters:
      fitTime - the value for the fitTime record component
      scoreTime - the value for the scoreTime record component
      size - the value for the size record component
      rss - the value for the rss record component
      mse - the value for the mse record component
      rmse - the value for the rmse record component
      mad - the value for the mad record component
      r2 - the value for the r2 record component
  • Method Details

    • 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
    • of

      public static RegressionMetrics of(double fitTime, double scoreTime, double[] truth, double[] prediction)
      Computes the regression metrics.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      truth - the ground truth.
      prediction - the predictions.
      Returns:
      the validation metrics.
    • of

      public static <T, M extends Regression<T>> RegressionMetrics of(M model, T[] testx, double[] testy)
      Validates a model on a test data.
      Type Parameters:
      T - the data type of samples.
      M - the model type.
      Parameters:
      model - the model.
      testx - the validation data.
      testy - the responsible variable of validation data.
      Returns:
      the validation metrics.
    • of

      public static <T, M extends Regression<T>> RegressionMetrics of(double fitTime, M model, T[] testx, double[] testy)
      Validates a model on a test data.
      Type Parameters:
      T - the data type of samples.
      M - the model type.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      model - the model.
      testx - the validation data.
      testy - the responsible variable of validation data.
      Returns:
      the validation metrics.
    • of

      public static <M extends DataFrameRegression> RegressionMetrics of(M model, Formula formula, DataFrame test)
      Trains and validates a model on a train/validation split.
      Type Parameters:
      M - the model type.
      Parameters:
      model - the model.
      formula - the model formula.
      test - the validation data.
      Returns:
      the validation metrics.
    • of

      public static <M extends DataFrameRegression> RegressionMetrics of(double fitTime, M model, Formula formula, DataFrame test)
      Trains and validates a model on a train/validation split.
      Type Parameters:
      M - the model type.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      model - the model.
      formula - the model formula.
      test - the validation data.
      Returns:
      the validation metrics.
    • 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 '=='.
      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.
    • fitTime

      public double fitTime()
      Returns the value of the fitTime record component.
      Returns:
      the value of the fitTime record component
    • scoreTime

      public double scoreTime()
      Returns the value of the scoreTime record component.
      Returns:
      the value of the scoreTime record component
    • size

      public int size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • rss

      public double rss()
      Returns the value of the rss record component.
      Returns:
      the value of the rss record component
    • mse

      public double mse()
      Returns the value of the mse record component.
      Returns:
      the value of the mse record component
    • rmse

      public double rmse()
      Returns the value of the rmse record component.
      Returns:
      the value of the rmse record component
    • mad

      public double mad()
      Returns the value of the mad record component.
      Returns:
      the value of the mad record component
    • r2

      public double r2()
      Returns the value of the r2 record component.
      Returns:
      the value of the r2 record component