Package deepnetts.eval
Class ConfusionMatrix
java.lang.Object
deepnetts.eval.ConfusionMatrix
Confusion matrix contains raw classifier test results.
It counts number of true and false predictions with respect to actual/target class of the given examples in test(evaluation) set.
Rows correspond to actual/target classes, and columns to predicted
Predicted
F T
Actual/target F TN FP
Actual/target T FN TP
https://en.wikipedia.org/wiki/Confusion_matrix
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A label for items falsely classified as negative, which are actually positive.static final String
A label for items falsely classified as positive, which are actually negative.static final String
A label for items classified as negative which are really negative.static final String
A label for items classified as positive which are really positive. -
Constructor Summary
ConstructorsConstructorDescriptionConfusionMatrix
(String[] classLabels) Creates a new confusion matrix for specified class labels -
Method Summary
Modifier and TypeMethodDescriptionfinal int
get
(int actualIdx, int predictedIdx) Returns a value of confusion matrix at specified position.final int
final String[]
int
How many positive items has been (falsely) classified as negative.int
getFalseNegative
(int clsIdx) int
Returns number of false positive classifications.int
getFalsePositive
(int clsIdx) int
int
int
getTrueNegative
(int clsIdx) int
Return true positive metric for binary classification.int
getTruePositive
(int clsIdx) Returns true positive metric for specified class idx for multiclass classification.final void
inc
(int actualIdx, int predictedIdx) Increments matrix value at specified position.toString()
-
Field Details
-
TRUE_POSITIVE
A label for items classified as positive which are really positive.- See Also:
-
TRUE_NEGATIVE
A label for items classified as negative which are really negative.- See Also:
-
FALSE_POSITIVE
A label for items falsely classified as positive, which are actually negative.- See Also:
-
FALSE_NEGATIVE
A label for items falsely classified as negative, which are actually positive.- See Also:
-
-
Constructor Details
-
ConfusionMatrix
Creates a new confusion matrix for specified class labels- Parameters:
classLabels
-
-
-
Method Details
-
get
public final int get(int actualIdx, int predictedIdx) Returns a value of confusion matrix at specified position.- Parameters:
actualIdx
- target/actual class idx - corresponds to columnpredictedIdx
- predicted class idx - corresponds to row- Returns:
- value of confusion matrix at specified position
-
inc
public final void inc(int actualIdx, int predictedIdx) Increments matrix value at specified position.- Parameters:
actualIdx
- class idx of actual class - corresponds to rowpredictedIdx
- class idx of predicted class - corresponds to column
-
getClassCount
public final int getClassCount() -
toString
-
getTruePositive
public int getTruePositive()Return true positive metric for binary classification. True positives metric tells us percent of positive examples which are recognized by the classifier as positive. Or in other words percent of correct predictions for the given positive examples.- Returns:
- true positive metric for binary classification
-
getTruePositive
public int getTruePositive(int clsIdx) Returns true positive metric for specified class idx for multiclass classification. True positive metric tells how many examples are correctly classified as a positive examples of the given class.- Parameters:
clsIdx
- Index of class for which true positive value is returned- Returns:
-
getTrueNegative
public int getTrueNegative() -
getTrueNegative
public int getTrueNegative(int clsIdx) -
getFalsePositive
public int getFalsePositive()Returns number of false positive classifications. Items that do not belong to specific class, but they are recognized as they do Only for binary classification- Returns:
-
getFalsePositive
public int getFalsePositive(int clsIdx) -
getFalseNegative
public int getFalseNegative(int clsIdx) -
getFalseNegative
public int getFalseNegative()How many positive items has been (falsely) classified as negative.- Returns:
- How many positive items has been (falsely) classified as negative
-
getClassLabels
-
getTotalItems
public int getTotalItems()
-