public final class LabelConfusionMatrix extends Object implements ConfusionMatrix<Label>
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 and Description |
---|
LabelConfusionMatrix(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.
|
Modifier and Type | Method and Description |
---|---|
double |
confusion(Label predicted,
Label trueClass)
The number of times the supplied predicted label was returned for the supplied true class.
|
double |
fn(Label cls)
The number of false negatives for the supplied label.
|
double |
fp(Label cls)
The number of false positives for the supplied label.
|
ImmutableOutputInfo<Label> |
getDomain()
Returns the classification domain that this confusion matrix operates over.
|
void |
setLabelOrder(List<Label> labelOrder)
Sets the label order used in
toString() . |
double |
support()
The number of examples this confusion matrix has seen.
|
double |
support(Label label)
The number of examples with this true label this confusion matrix has seen.
|
double |
tn(Label cls)
The number of true negatives for the supplied label.
|
String |
toHTML()
Emits a HTML table representation of the Confusion Matrix.
|
String |
toString() |
double |
tp(Label cls)
The number of true positives for the supplied label.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
fn, fp, sumOverOutputs, tn, tp
public LabelConfusionMatrix(Model<Label> model, List<Prediction<Label>> predictions)
model
- The model to use for the label information.predictions
- The predictions.public LabelConfusionMatrix(ImmutableOutputInfo<Label> domain, List<Prediction<Label>> predictions)
domain
- The label information.predictions
- The predictions.IllegalArgumentException
- If the domain doesn't contain all the predictions.public ImmutableOutputInfo<Label> getDomain()
ConfusionMatrix
getDomain
in interface ConfusionMatrix<Label>
public double support()
ConfusionMatrix
support
in interface ConfusionMatrix<Label>
public double support(Label label)
ConfusionMatrix
support
in interface ConfusionMatrix<Label>
label
- The label.public double tp(Label cls)
ConfusionMatrix
tp
in interface ConfusionMatrix<Label>
cls
- The label.public double fp(Label cls)
ConfusionMatrix
fp
in interface ConfusionMatrix<Label>
cls
- The label.public double fn(Label cls)
ConfusionMatrix
fn
in interface ConfusionMatrix<Label>
cls
- The label.public double tn(Label cls)
ConfusionMatrix
tn
in interface ConfusionMatrix<Label>
cls
- The label.public double confusion(Label predicted, Label trueClass)
ConfusionMatrix
confusion
in interface ConfusionMatrix<Label>
predicted
- The predicted label.trueClass
- The true label.predictedLabel
when the true label was trueLabel
.public void setLabelOrder(List<Label> labelOrder)
toString()
.labelOrder
- The label order to use.public String toHTML()
Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.