Class LabelConfusionMatrix
java.lang.Object
org.tribuo.classification.evaluation.LabelConfusionMatrix
- All Implemented Interfaces:
ConfusionMatrix<Label>
A confusion matrix for
Label
s.
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
ConstructorDescriptionLabelConfusionMatrix
(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 TypeMethodDescriptiondouble
The number of times the supplied predicted label was returned for the supplied true class.double
The number of false negatives for the supplied label.double
The 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.void
setLabelOrder
(List<Label> newLabelOrder) Sets the label order used intoString()
.double
support()
The number of examples this confusion matrix has seen.double
The number of examples with this true label this confusion matrix has seen.double
The number of true negatives for the supplied label.toHTML()
Emits a HTML table representation of the Confusion Matrix.toString()
double
The number of true positives for the supplied label.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:ConfusionMatrix
Returns the classification domain that this confusion matrix operates over.- Specified by:
getDomain
in interfaceConfusionMatrix<Label>
- Returns:
- The classification domain.
-
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 interfaceConfusionMatrix<Label>
- 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 interfaceConfusionMatrix<Label>
- Returns:
- The number of examples.
-
support
Description copied from interface:ConfusionMatrix
The number of examples with this true label this confusion matrix has seen.- Specified by:
support
in interfaceConfusionMatrix<Label>
- Parameters:
label
- The label.- Returns:
- The number of examples.
-
tp
Description copied from interface:ConfusionMatrix
The number of true positives for the supplied label.- Specified by:
tp
in interfaceConfusionMatrix<Label>
- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
fp
Description copied from interface:ConfusionMatrix
The number of false positives for the supplied label.- Specified by:
fp
in interfaceConfusionMatrix<Label>
- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
fn
Description copied from interface:ConfusionMatrix
The number of false negatives for the supplied label.- Specified by:
fn
in interfaceConfusionMatrix<Label>
- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
tn
Description copied from interface:ConfusionMatrix
The number of true negatives for the supplied label.- Specified by:
tn
in interfaceConfusionMatrix<Label>
- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
confusion
Description copied from interface:ConfusionMatrix
The number of times the supplied predicted label was returned for the supplied true class.- Specified by:
confusion
in interfaceConfusionMatrix<Label>
- Parameters:
predicted
- The predicted label.trueClass
- The true label.- Returns:
- The number of examples predicted as
predictedLabel
when 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:
setLabelOrder
in 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:
getLabelOrder
in 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.
-