Class MultiLabelConfusionMatrix

java.lang.Object
org.tribuo.multilabel.evaluation.MultiLabelConfusionMatrix
All Implemented Interfaces:
ConfusionMatrix<MultiLabel>

public final class MultiLabelConfusionMatrix extends Object implements ConfusionMatrix<MultiLabel>
A ConfusionMatrix which accepts MultiLabels.

In a multi-label confusion matrix M,

 tn = M[:, 0, 0]
 fn = M[:, 0, 1]
 fp = M[:, 1, 0]
 tp = M[:, 1, 1]
 

For class-wise values,

 tn(class i) = M[i, 0, 0]
 fn(class i) = M[i, 0, 1]
 fp(class i) = M[i, 1, 0]
 tp(class i) = M[i, 1, 1]
 
  • Constructor Details

    • MultiLabelConfusionMatrix

      public MultiLabelConfusionMatrix(Model<MultiLabel> model, List<Prediction<MultiLabel>> predictions)
      Constructs a multi-label confusion matrix for the specified model and predictions.
      Parameters:
      model - The model.
      predictions - The predictions.
  • Method Details

    • support

      public double support(MultiLabel cls)
      Description copied from interface: ConfusionMatrix
      The number of examples with this true label this confusion matrix has seen.
      Specified by:
      support in interface ConfusionMatrix<MultiLabel>
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • getDomain

      public ImmutableOutputInfo<MultiLabel> getDomain()
      Description copied from interface: ConfusionMatrix
      Returns the classification domain that this confusion matrix operates over.
      Specified by:
      getDomain in interface ConfusionMatrix<MultiLabel>
      Returns:
      The classification domain.
    • observed

      public Set<MultiLabel> observed()
      Description copied from interface: ConfusionMatrix
      The values this confusion matrix has seen.

      The default implementation is provided for compatibility reasons and will be removed in a future major release. It defaults to returning the output domain.

      Specified by:
      observed in interface ConfusionMatrix<MultiLabel>
      Returns:
      The set of observed outputs.
    • support

      public double support()
      Description copied from interface: ConfusionMatrix
      The number of examples this confusion matrix has seen.
      Specified by:
      support in interface ConfusionMatrix<MultiLabel>
      Returns:
      The number of examples.
    • tp

      public double tp(MultiLabel cls)
      Description copied from interface: ConfusionMatrix
      The number of true positives for the supplied label.
      Specified by:
      tp in interface ConfusionMatrix<MultiLabel>
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • fp

      public double fp(MultiLabel cls)
      Description copied from interface: ConfusionMatrix
      The number of false positives for the supplied label.
      Specified by:
      fp in interface ConfusionMatrix<MultiLabel>
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • fn

      public double fn(MultiLabel cls)
      Description copied from interface: ConfusionMatrix
      The number of false negatives for the supplied label.
      Specified by:
      fn in interface ConfusionMatrix<MultiLabel>
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • tn

      public double tn(MultiLabel cls)
      Description copied from interface: ConfusionMatrix
      The number of true negatives for the supplied label.
      Specified by:
      tn in interface ConfusionMatrix<MultiLabel>
      Parameters:
      cls - The label.
      Returns:
      The number of examples.
    • confusion

      public double confusion(MultiLabel predicted, MultiLabel truth)
      Description copied from interface: ConfusionMatrix
      The number of times the supplied predicted label was returned for the supplied true class.
      Specified by:
      confusion in interface ConfusionMatrix<MultiLabel>
      Parameters:
      predicted - The predicted label.
      truth - The true label.
      Returns:
      The number of examples predicted as predictedLabel when the true label was trueLabel.
    • setLabelOrder

      public void setLabelOrder(List<MultiLabel> labelOrder)
      Sets the label order used in toString().

      If the label order is a subset of the labels in the domain, only the labels present in the label order will be displayed.

      Specified by:
      setLabelOrder in interface ConfusionMatrix<MultiLabel>
      Parameters:
      labelOrder - The label order to use.
    • getLabelOrder

      public List<MultiLabel> getLabelOrder()
      Gets the current label order.

      If the label order is a subset of the labels in the domain, only the labels present in the label order will be displayed.

      Specified by:
      getLabelOrder in interface ConfusionMatrix<MultiLabel>
      Returns:
      The label order.
    • toString

      public String toString()
      Overrides:
      toString in class Object