Class R2

  • All Implemented Interfaces:
    org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure<java.lang.Double,​org.api4.java.ai.ml.regression.evaluation.IRegressionPrediction>

    public class R2
    extends ARegressionMeasure
    The R^2, aka. the coefficient of determination describes the proportion of the variance in the target variable and the predicted values. The formula of R^2 is as follows: (\sum_i (y^\hat_i - \bar{y})^2) / (\sum_i (y_i - \bar{y})^2) For predictions not worse than prediting constantly the mean of the target variable, R^2 resides within the [0, 1] interval. Caution: For worse predictions the coefficient of determination becomes *negative*.
    • Constructor Summary

      Constructors 
      Constructor Description
      R2()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double score​(java.util.List<? extends java.lang.Double> expected, java.util.List<? extends org.api4.java.ai.ml.regression.evaluation.IRegressionPrediction> predicted)
      If this performance measure is originally a loss function its loss is transformed into a score by multiplying the loss with -1.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure

        loss, loss, score
    • Constructor Detail

      • R2

        public R2()
    • Method Detail

      • score

        public double score​(java.util.List<? extends java.lang.Double> expected,
                            java.util.List<? extends org.api4.java.ai.ml.regression.evaluation.IRegressionPrediction> predicted)
        Description copied from class: APredictionPerformanceMeasure
        If this performance measure is originally a loss function its loss is transformed into a score by multiplying the loss with -1. (score=-loss).
        Specified by:
        score in interface org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure<java.lang.Double,​org.api4.java.ai.ml.regression.evaluation.IRegressionPrediction>
        Overrides:
        score in class APredictionPerformanceMeasure<java.lang.Double,​org.api4.java.ai.ml.regression.evaluation.IRegressionPrediction>