Class LabelConfusionMatrix
java.lang.Object
org.tribuo.classification.evaluation.LabelConfusionMatrix
- All Implemented Interfaces:
ConfusionMatrix<Label>
A confusion matrix for
Labels.
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.
-
Constructor Summary
ConstructorsConstructorDescriptionLabelConfusionMatrix(ImmutableOutputInfo<Label> domain, List<Prediction<Label>> predictions) Creates a confusion matrix from the supplied predictions and label info.LabelConfusionMatrix(Model<Label> model, List<Prediction<Label>> predictions) Creates a confusion matrix from the supplied predictions, using the label info from the supplied model. -
Method Summary
Modifier and TypeMethodDescriptiondoubleThe number of times the supplied predicted label was returned for the supplied true class.doubleThe number of false negatives for the supplied label.doubleThe number of false positives for the supplied label.Returns the classification domain that this confusion matrix operates over.Gets the current label order.observed()The values this confusion matrix has seen.voidsetLabelOrder(List<Label> newLabelOrder) Sets the label order used intoString().doublesupport()The number of examples this confusion matrix has seen.doubleThe number of examples with this true label this confusion matrix has seen.doubleThe number of true negatives for the supplied label.toHTML()Emits a HTML table representation of the Confusion Matrix.toString()doubleThe number of true positives for the supplied label.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tribuo.classification.evaluation.ConfusionMatrix
fn, fp, tn, tp
-
Constructor Details
-
LabelConfusionMatrix
Creates a confusion matrix from the supplied predictions, using the label info from the supplied model.- Parameters:
model- The model to use for the label information.predictions- The predictions.
-
LabelConfusionMatrix
Creates a confusion matrix from the supplied predictions and label info.- Parameters:
domain- The label information.predictions- The predictions.- Throws:
IllegalArgumentException- If the domain doesn't contain all the predictions.
-
-
Method Details
-
getDomain
Description copied from interface:ConfusionMatrixReturns the classification domain that this confusion matrix operates over.- Specified by:
getDomainin interfaceConfusionMatrix<Label>- Returns:
- The classification domain.
-
observed
Description copied from interface:ConfusionMatrixThe 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:
observedin interfaceConfusionMatrix<Label>- Returns:
- The set of observed outputs.
-
support
public double support()Description copied from interface:ConfusionMatrixThe number of examples this confusion matrix has seen.- Specified by:
supportin interfaceConfusionMatrix<Label>- Returns:
- The number of examples.
-
support
Description copied from interface:ConfusionMatrixThe number of examples with this true label this confusion matrix has seen.- Specified by:
supportin interfaceConfusionMatrix<Label>- Parameters:
label- The label.- Returns:
- The number of examples.
-
tp
Description copied from interface:ConfusionMatrixThe number of true positives for the supplied label.- Specified by:
tpin interfaceConfusionMatrix<Label>- Parameters:
cls- The label.- Returns:
- The number of examples.
-
fp
Description copied from interface:ConfusionMatrixThe number of false positives for the supplied label.- Specified by:
fpin interfaceConfusionMatrix<Label>- Parameters:
cls- The label.- Returns:
- The number of examples.
-
fn
Description copied from interface:ConfusionMatrixThe number of false negatives for the supplied label.- Specified by:
fnin interfaceConfusionMatrix<Label>- Parameters:
cls- The label.- Returns:
- The number of examples.
-
tn
Description copied from interface:ConfusionMatrixThe number of true negatives for the supplied label.- Specified by:
tnin interfaceConfusionMatrix<Label>- Parameters:
cls- The label.- Returns:
- The number of examples.
-
confusion
Description copied from interface:ConfusionMatrixThe number of times the supplied predicted label was returned for the supplied true class.- Specified by:
confusionin interfaceConfusionMatrix<Label>- Parameters:
predicted- The predicted label.trueClass- The true label.- Returns:
- The number of examples predicted as
predictedLabelwhen the true label wastrueLabel.
-
setLabelOrder
Sets the label order used intoString().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:
setLabelOrderin interfaceConfusionMatrix<Label>- Parameters:
newLabelOrder- The label order to use.
-
getLabelOrder
Gets the current label order. May trigger order instantiation if the label order has not been set.- Specified by:
getLabelOrderin interfaceConfusionMatrix<Label>- Returns:
- The label order.
-
toString
-
toHTML
Emits a HTML table representation of the Confusion Matrix.- Returns:
- The confusion matrix as a HTML table.
-