Class ConfusionMatrix

java.lang.Object
deepnetts.eval.ConfusionMatrix

public class ConfusionMatrix extends Object
Confusion matrix contains raw classifier test results. It counts number of true and false predictions with respect to actual/target class of the given examples in test(evaluation) set. Rows correspond to actual/target classes, and columns to predicted Predicted F T Actual/target F TN FP Actual/target T FN TP https://en.wikipedia.org/wiki/Confusion_matrix
  • Field Details

    • TRUE_POSITIVE

      public static final String TRUE_POSITIVE
      A label for items classified as positive which are really positive.
      See Also:
    • TRUE_NEGATIVE

      public static final String TRUE_NEGATIVE
      A label for items classified as negative which are really negative.
      See Also:
    • FALSE_POSITIVE

      public static final String FALSE_POSITIVE
      A label for items falsely classified as positive, which are actually negative.
      See Also:
    • FALSE_NEGATIVE

      public static final String FALSE_NEGATIVE
      A label for items falsely classified as negative, which are actually positive.
      See Also:
  • Constructor Details

    • ConfusionMatrix

      public ConfusionMatrix(String[] classLabels)
      Creates a new confusion matrix for specified class labels
      Parameters:
      classLabels -
  • Method Details

    • get

      public final int get(int actualIdx, int predictedIdx)
      Returns a value of confusion matrix at specified position.
      Parameters:
      actualIdx - target/actual class idx - corresponds to column
      predictedIdx - predicted class idx - corresponds to row
      Returns:
      value of confusion matrix at specified position
    • inc

      public final void inc(int actualIdx, int predictedIdx)
      Increments matrix value at specified position.
      Parameters:
      actualIdx - class idx of actual class - corresponds to row
      predictedIdx - class idx of predicted class - corresponds to column
    • getClassCount

      public final int getClassCount()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTruePositive

      public int getTruePositive()
      Return true positive metric for binary classification. True positives metric tells us percent of positive examples which are recognized by the classifier as positive. Or in other words percent of correct predictions for the given positive examples.
      Returns:
      true positive metric for binary classification
    • getTruePositive

      public int getTruePositive(int clsIdx)
      Returns true positive metric for specified class idx for multiclass classification. True positive metric tells how many examples are correctly classified as a positive examples of the given class.
      Parameters:
      clsIdx - Index of class for which true positive value is returned
      Returns:
    • getTrueNegative

      public int getTrueNegative()
    • getTrueNegative

      public int getTrueNegative(int clsIdx)
    • getFalsePositive

      public int getFalsePositive()
      Returns number of false positive classifications. Items that do not belong to specific class, but they are recognized as they do Only for binary classification
      Returns:
    • getFalsePositive

      public int getFalsePositive(int clsIdx)
    • getFalseNegative

      public int getFalseNegative(int clsIdx)
    • getFalseNegative

      public int getFalseNegative()
      How many positive items has been (falsely) classified as negative.
      Returns:
      How many positive items has been (falsely) classified as negative
    • getClassLabels

      public final String[] getClassLabels()
    • getTotalItems

      public int getTotalItems()