Interface ConfusionMatrix<T extends Classifiable<T>>
- Type Parameters:
T
- The type of the output.
- All Known Implementing Classes:
LabelConfusionMatrix
,MultiLabelConfusionMatrix
public interface ConfusionMatrix<T extends Classifiable<T>>
A confusion matrix for
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.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.
-
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.
-