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 SummaryFieldsModifier and TypeFieldDescriptionstatic final StringA label for items falsely classified as negative, which are actually positive.static final StringA label for items falsely classified as positive, which are actually negative.static final StringA label for items classified as negative which are really negative.static final StringA label for items classified as positive which are really positive.
- 
Constructor SummaryConstructorsConstructorDescriptionConfusionMatrix(String[] classLabels) Creates a new confusion matrix for specified class labels
- 
Method SummaryModifier and TypeMethodDescriptionfinal intget(int actualIdx, int predictedIdx) Returns a value of confusion matrix at specified position.final intfinal String[]intHow many positive items has been (falsely) classified as negative.intgetFalseNegative(int clsIdx) intReturns number of false positive classifications.intgetFalsePositive(int clsIdx) intintintgetTrueNegative(int clsIdx) intReturn true positive metric for binary classification.intgetTruePositive(int clsIdx) Returns true positive metric for specified class idx for multiclass classification.final voidinc(int actualIdx, int predictedIdx) Increments matrix value at specified position.toString()
- 
Field Details- 
TRUE_POSITIVEA label for items classified as positive which are really positive.- See Also:
 
- 
TRUE_NEGATIVEA label for items classified as negative which are really negative.- See Also:
 
- 
FALSE_POSITIVEA label for items falsely classified as positive, which are actually negative.- See Also:
 
- 
FALSE_NEGATIVEA label for items falsely classified as negative, which are actually positive.- See Also:
 
 
- 
- 
Constructor Details- 
ConfusionMatrixCreates a new confusion matrix for specified class labels- Parameters:
- classLabels-
 
 
- 
- 
Method Details- 
getpublic final int get(int actualIdx, int predictedIdx) Returns a value of confusion matrix at specified position.- Parameters:
- actualIdx- target/actual class idx - corresponds to column
- predictedIdx- predicted class idx - corresponds to row
- Returns:
- value of confusion matrix at specified position
 
- 
incpublic final void inc(int actualIdx, int predictedIdx) Increments matrix value at specified position.- Parameters:
- actualIdx- class idx of actual class - corresponds to row
- predictedIdx- class idx of predicted class - corresponds to column
 
- 
getClassCountpublic final int getClassCount()
- 
toString
- 
getTruePositivepublic 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
 
- 
getTruePositivepublic 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:
 
- 
getTrueNegativepublic int getTrueNegative()
- 
getTrueNegativepublic int getTrueNegative(int clsIdx) 
- 
getFalsePositivepublic 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:
 
- 
getFalsePositivepublic int getFalsePositive(int clsIdx) 
- 
getFalseNegativepublic int getFalseNegative(int clsIdx) 
- 
getFalseNegativepublic int getFalseNegative()How many positive items has been (falsely) classified as negative.- Returns:
- How many positive items has been (falsely) classified as negative
 
- 
getClassLabels
- 
getTotalItemspublic int getTotalItems()
 
-