|
Darwin
1.10(beta)
|
Utility class for computing and printing confusion matrices. More...
Public Member Functions | |
| drwnConfusionMatrix (int n) | |
construct a confusion matrix for n classes | |
| drwnConfusionMatrix (int n, int m) | |
construct a confusion matrix for n actual and m predicted classes | |
| int | numRows () const |
| returns the number of rows | |
| int | numCols () const |
| returns the number of columns | |
| void | clear () |
| clear all counts in the confusion matrix | |
| void | accumulate (int actual, int predicted) |
| accumulate a prediction/actual pair | |
| void | accumulate (const std::vector< int > &actual, const std::vector< int > &predicted) |
| accumulate a set of prediction/actual pairs | |
| void | accumulate (const drwnClassifierDataset &dataset, drwnClassifier const *classifier) |
| accumulate classification results | |
| void | accumulate (const drwnConfusionMatrix &confusion) |
| accumulate counts from a different confusion matrix of the same size | |
| void | printCounts (std::ostream &os=std::cout, const char *header=NULL) const |
| print the confusion matrix | |
| void | printRowNormalized (std::ostream &os=std::cout, const char *header=NULL) const |
| print the confusion normalized by row | |
| void | printColNormalized (std::ostream &os=std::cout, const char *header=NULL) const |
| print the confusion normalized by column | |
| void | printNormalized (std::ostream &os=std::cout, const char *header=NULL) const |
| print the confusion matrix normalized by total count | |
| void | printPrecisionRecall (std::ostream &os=std::cout, const char *header=NULL) const |
| print precision and recall for each class | |
| void | printF1Score (std::ostream &os=std::cout, const char *header=NULL) const |
| print the F1-score for each class | |
| void | printJaccard (std::ostream &os=std::cout, const char *header=NULL) const |
| print the Jaccard (intersection-over-union) score for each class | |
| void | write (std::ostream &os) const |
| write the confusion matrix | |
| void | read (std::istream &is) |
| read a confusion matrix | |
| double | rowSum (int n) const |
| returns the sum of entries along a row | |
| double | colSum (int m) const |
| returns the sum of entries down a column | |
| double | diagSum () const |
| returns the sum of entries along the diagonal | |
| double | totalSum () const |
| returns the sum of all entries in the confusion matrix | |
| double | accuracy () const |
| diagSum / totalSum | |
| double | avgPrecision () const |
| average of TP / (TP + FP); diagonal / colSum | |
| double | avgRecall () const |
| average of TP / (TP + FN); diagonal / rowSum | |
| double | avgJaccard () const |
| average of TP / (TP + FP + FN); diagonal / (rowSum + colSum - diagonal) | |
| double | precision (int n) const |
| precision for class n | |
| double | recall (int n) const |
| recall for class n | |
| double | jaccard (int n) const |
| jaccard coefficient for class n | |
| const unsigned & | operator() (int x, int y) const |
returns the counts at location (x,y) | |
| unsigned & | operator() (int x, int y) |
accesses the counts at location (x,y) | |
Static Public Attributes | |
| static std::string | COL_SEP |
| string for separating columns when printing | |
| static std::string | ROW_BEGIN |
| string for starting a row when printing | |
| static std::string | ROW_END |
| string for ending a row when printing | |
Protected Attributes | |
| std::vector< std::vector< unsigned > > | _matrix |
Utility class for computing and printing confusion matrices.
A negative actual/predicted class is considered unknown and not counted. The Jaccard coefficient for a class is TP / (TP + FP + FN).
1.8.13