Interface ConfusionMatrix<T extends Classifiable<T>>

Type Parameters:
T - The type of the output.
All Known Implementing Classes:
LabelConfusionMatrix, MultiLabelConfusionMatrix

public interface ConfusionMatrix<T extends Classifiable<T>>
A confusion matrix for Classifiables.

We interpret it as follows: C[i, j] = k means "the TRUE class 'j' was PREDICTED to be class 'i' a total of 'k' times".

In other words, the row indices correspond to the model's predictions, and the column indices correspond to the ground truth.

  • Method Summary

    Modifier and Type
    Method
    Description
    double
    confusion(T predictedLabel, T trueLabel)
    The number of times the supplied predicted label was returned for the supplied true class.
    default double
    fn()
    The total number of false negatives.
    double
    fn(T cls)
    The number of false negatives for the supplied label.
    default double
    fp()
    The total number of false positives.
    double
    fp(T cls)
    The number of false positives for the supplied label.
    Returns the classification domain that this confusion matrix operates over.
    static <T extends Classifiable<T>>
    double
    Sums the supplied getter over the domain.
    double
    The number of examples this confusion matrix has seen.
    double
    support(T cls)
    The number of examples with this true label this confusion matrix has seen.
    default double
    tn()
    The total number of true negatives.
    double
    tn(T cls)
    The number of true negatives for the supplied label.
    default double
    tp()
    The total number of true positives.
    double
    tp(T cls)
    The number of true positives for the supplied label.
  • Method Details

    • getDomain

      ImmutableOutputInfo<T> getDomain()
      Returns the classification domain that this confusion matrix operates over.
      Returns:
      The classification domain.
    • support

      double support()
      The number of examples this confusion matrix has seen.
      Returns:
      The number of examples.
    • support

      double support(T cls)
      The number of examples with this true label this confusion matrix has seen.
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • tp

      double tp(T cls)
      The number of true positives for the supplied label.
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • fp

      double fp(T cls)
      The number of false positives for the supplied label.
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • fn

      double fn(T cls)
      The number of false negatives for the supplied label.
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • tn

      double tn(T cls)
      The number of true negatives for the supplied label.
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • confusion

      double confusion(T predictedLabel, T trueLabel)
      The number of times the supplied predicted label was returned for the supplied true class.
      Parameters:
      predictedLabel - The predicted label.
      trueLabel - The true label.
      Returns:
      The number of examples predicted as predictedLabel when the true label was trueLabel.
    • tp

      default double tp()
      The total number of true positives.
      Returns:
      The total true positives.
    • fp

      default double fp()
      The total number of false positives.
      Returns:
      The total false positives.
    • fn

      default double fn()
      The total number of false negatives.
      Returns:
      The total false negatives.
    • tn

      default double tn()
      The total number of true negatives.
      Returns:
      The total true negatives.
    • sumOverOutputs

      static <T extends Classifiable<T>> double sumOverOutputs(ImmutableOutputInfo<T> domain, ToDoubleFunction<T> getter)
      Sums the supplied getter over the domain.
      Type Parameters:
      T - The type of the output.
      Parameters:
      domain - The domain to sum over.
      getter - The getter to use.
      Returns:
      The total summed over the domain.