curfil  ..
 All Classes Functions Variables Typedefs Friends Groups Pages
Public Member Functions | List of all members
curfil::ConfusionMatrix Class Reference

Helper class to maintain a n×n confusion matrix. More...

#include <predict.h>

Public Member Functions

 ConfusionMatrix ()
 Create an empty confusion matrix that can later be resized with resize().
 ConfusionMatrix (const ConfusionMatrix &other)
 create a confusion matrix using the attribute values of another matrix
 ConfusionMatrix (size_t numClasses)
 Create a confusion matrix of size numClasses × numClasses with zero initial values.
 ConfusionMatrix (size_t numClasses, std::vector< LabelType > ignoredLabels)
 Create a confusion matrix of size numClasses x numClasses and sets which labels should be ignored in the calculations.
ConfusionMatrixoperator= (const ConfusionMatrix &other)
 copies the attribute values of another confusion matrix
void reset ()
 Reset all per-class counters to zero.
void resize (unsigned int numClasses)
 Resize the confusion matrix.
bool isNormalized () const
void operator+= (const ConfusionMatrix &other)
 adds the data values of another confusion matrix
cuv::reference< double,
cuv::host_memory_space
operator() (int label, int prediction)
double operator() (int label, int prediction) const
void increment (int label, int prediction)
 Increment the counter in the matrix for the given label and the prediction.
unsigned int getNumClasses () const
void normalize ()
 Normalizes the confusion matrix such that the sum of the predictions equals one for every label (class).
double averageClassAccuracy (bool includeVoid=true) const
 Calculate the average per-class accuracy which is equal to the average over the diagonal.

Detailed Description

Helper class to maintain a n×n confusion matrix.

Construction of the confusion matrix is usually a two-phase process.

  1. Increment the label/prediction counters
  2. Normalize the confusion matrix such that the sum over the predictions for every class is 1.

Definition at line 20 of file predict.h.

Member Function Documentation

double curfil::ConfusionMatrix::averageClassAccuracy ( bool  includeVoid = true) const

Calculate the average per-class accuracy which is equal to the average over the diagonal.

Parameters
includeVoidif false, the class 0 is excluded in the calculation.
unsigned int curfil::ConfusionMatrix::getNumClasses ( ) const
inline
Returns
n for a confusion matrix of size n×n

Definition at line 122 of file predict.h.

void curfil::ConfusionMatrix::increment ( int  label,
int  prediction 
)
inline

Increment the counter in the matrix for the given label and the prediction.

Increment can only be used before the confusion matrix is normalized!

Definition at line 110 of file predict.h.

bool curfil::ConfusionMatrix::isNormalized ( ) const
inline
Returns
true if and only if the confusion matrix was normalized.
See Also
normalize()

Definition at line 82 of file predict.h.

cuv::reference<double, cuv::host_memory_space> curfil::ConfusionMatrix::operator() ( int  label,
int  prediction 
)
inline
Returns
the probability and host_memory_space associated with the true and predicted classes

Definition at line 95 of file predict.h.

double curfil::ConfusionMatrix::operator() ( int  label,
int  prediction 
) const
inline
Returns
the probability associated with the true and predicted classes

Definition at line 102 of file predict.h.

void curfil::ConfusionMatrix::resize ( unsigned int  numClasses)

Resize the confusion matrix.

This operation implies a reset.

Parameters
numClassesresize the confusion matrix to numClasses × numClasses.

The documentation for this class was generated from the following file: