Class MatthewsCorrelation

java.lang.Object
smile.validation.metric.MatthewsCorrelation
All Implemented Interfaces:
Serializable, ClassificationMetric

public class MatthewsCorrelation extends Object implements ClassificationMetric
Matthews correlation coefficient. The MCC is in essence a correlation coefficient between the observed and predicted binary classifications. It is considered as a balanced measure for binary classification, even in unbalanced data sets. It varies between -1 (perfect disagreement) and +1 (perfect agreement). When it is 0, the model is not better then random.
See Also:
  • Field Details

  • Constructor Details

    • MatthewsCorrelation

      public MatthewsCorrelation()
  • Method Details

    • score

      public double score(int[] truth, int[] prediction)
      Description copied from interface: ClassificationMetric
      Returns a score to measure the quality of classification.
      Specified by:
      score in interface ClassificationMetric
      Parameters:
      truth - the true class labels.
      prediction - the predicted class labels.
      Returns:
      the metric.
    • of

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

      public String toString()
      Overrides:
      toString in class Object