Interface ConfusionMatrix<T extends Classifiable<T>>
- Type Parameters:
T
- The type of the output.
- All Known Implementing Classes:
LabelConfusionMatrix
,MultiLabelConfusionMatrix
Classifiable
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.
-
Method Summary
Modifier and TypeMethodDescriptiondouble
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
The number of false negatives for the supplied label.default double
fp()
The total number of false positives.double
The number of false positives for the supplied label.Returns the classification domain that this confusion matrix operates over.The label order this confusion matrix uses intoString
.observed()
The values this confusion matrix has seen.default void
setLabelOrder
(List<T> labelOrder) Sets the label order this confusion matrix uses intoString
.static <T extends Classifiable<T>>
doublesumOverOutputs
(ImmutableOutputInfo<T> domain, ToDoubleFunction<T> getter) Sums the supplied getter over the domain.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.default double
tn()
The total number of true negatives.double
The number of true negatives for the supplied label.default double
tp()
The total number of true positives.double
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
The number of examples with this true label this confusion matrix has seen.- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
tp
The number of true positives for the supplied label.- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
fp
The number of false positives for the supplied label.- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
fn
The number of false negatives for the supplied label.- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
tn
The number of true negatives for the supplied label.- Parameters:
cls
- The label.- Returns:
- The number of examples.
-
confusion
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 wastrueLabel
.
-
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.
-
observed
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.
- Returns:
- The set of observed outputs.
-
getLabelOrder
The label order this confusion matrix uses intoString
.The default implementation is provided for compatibility reasons and will be removed in a future major release. It defaults to the output domain iterated in hash order.
- Returns:
- An unmodifiable view on the label order.
-
setLabelOrder
Sets the label order this confusion matrix uses 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.
The default implementation does not set the label order and is provided for backwards compatibility reasons. It should be overridden in all subclasses to ensure correct behaviour, and this default implementation will be removed in a future major release.
- Parameters:
labelOrder
- The label order.
-
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.
-