Class R2

java.lang.Object
smile.validation.metric.R2
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<double[],double[]>, RegressionMetric

public class R2 extends Object implements RegressionMetric
R2. R2 coefficient of determination measures how well the regression line approximates the real data points. An R2 of 1.0 indicates that the regression line perfectly fits the data.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final R2
    Default instance.
  • Constructor Summary

    Constructors
    Constructor
    Description
    R2()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    of(double[] truth, double[] prediction)
    Calculates the R squared coefficient.
    double
    score(double[] truth, double[] prediction)
    Returns a score to measure the quality of regression.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface smile.validation.metric.RegressionMetric

    applyAsDouble
  • Field Details

    • instance

      public static final R2 instance
      Default instance.
  • Constructor Details

    • R2

      public R2()
  • Method Details

    • score

      public double score(double[] truth, double[] prediction)
      Description copied from interface: RegressionMetric
      Returns a score to measure the quality of regression.
      Specified by:
      score in interface RegressionMetric
      Parameters:
      truth - the true response values.
      prediction - the predicted response values.
      Returns:
      the metric.
    • of

      public static double of(double[] truth, double[] prediction)
      Calculates the R squared coefficient.
      Parameters:
      truth - the ground truth.
      prediction - the prediction.
      Returns:
      the metric.
    • toString

      public String toString()
      Overrides:
      toString in class Object