Direct Graphical Models  v.1.7.0
DirectGraphicalModels::CCMat Class Reference

Confusion matrix class. More...

#include <CMat.h>

Collaboration diagram for DirectGraphicalModels::CCMat:

Public Member Functions

 CCMat (byte nStates)
 Constructor. More...
 
virtual ~CCMat (void)
 
void reset (void)
 Resets class variables. More...
 
void save (const std::string &path, const std::string &name=std::string(), short idx=-1) const
 Saves the confusion matrix. More...
 
void load (const std::string &path, const std::string &name=std::string(), short idx=-1)
 Loads the confusion matrix. More...
 
void estimate (const Mat &gt, const Mat &solution, const Mat &mask=Mat())
 Estimates the confusion matrix. More...
 
void estimate (byte gt, byte solution)
 Estimates the confusion matrix. More...
 
Mat getConfusionMatrix (void) const
 Returns the confusion matrix. More...
 
float getAccuracy (void) const
 Returns the overall classification accuracy. More...
 

Private Attributes

CPriorEdgem_pConfusionMatrix
 COnfusion matrix container. More...
 

Detailed Description

Confusion matrix class.

This class estimates the confusion matrix, which
allows for evaluation of the classification results in terms of the overall classification accuracy, as well as of precision and recall.

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 20 of file CMat.h.

Constructor & Destructor Documentation

◆ CCMat()

DirectGraphicalModels::CCMat::CCMat ( byte  nStates)

Constructor.

Parameters
nStatesNumber of states (classes)

Definition at line 8 of file CMat.cpp.

◆ ~CCMat()

DirectGraphicalModels::CCMat::~CCMat ( void  )
virtual

Definition at line 14 of file CMat.cpp.

Member Function Documentation

◆ estimate() [1/2]

void DirectGraphicalModels::CCMat::estimate ( const Mat &  gt,
const Mat &  solution,
const Mat &  mask = Mat() 
)

Estimates the confusion matrix.

Parameters
gtMatrix, each element of which is a ground-truth state (class)
solutionMatrix with the predicted states, provided by classifier
maskOperation mask. Its non-zero elements indicate which matrix elements need to be stimated. Mask should have the same size as gt and solution and be of type CV_8UC1 .

Definition at line 34 of file CMat.cpp.

◆ estimate() [2/2]

void DirectGraphicalModels::CCMat::estimate ( byte  gt,
byte  solution 
)

Estimates the confusion matrix.

Parameters
gtThe ground-truth state (class)
solutionThe predicted state, provided by classifier

Definition at line 40 of file CMat.cpp.

Here is the call graph for this function:

◆ getAccuracy()

float DirectGraphicalModels::CCMat::getAccuracy ( void  ) const

Returns the overall classification accuracy.

Returns
The classification accuracy: percent of the correctly classified samples.

Definition at line 50 of file CMat.cpp.

Here is the call graph for this function:

◆ getConfusionMatrix()

Mat DirectGraphicalModels::CCMat::getConfusionMatrix ( void  ) const

Returns the confusion matrix.

The resulting confusion matrix may be visualized with help of CMarker::drawConfusionMatrix() function

Returns
Confusion matrix, where each value is given in percents. Mat(size: nStates x nStates; type: CV_32FC1)

Definition at line 45 of file CMat.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

void DirectGraphicalModels::CCMat::load ( const std::string &  path,
const std::string &  name = std::string(),
short  idx = -1 
)

Loads the confusion matrix.

Allows to re-use the class. Loads data to the file: "<path><name>_<idx>.dat".

Parameters
pathPath to the folder, containing the data file.
nameName of data file. If empty, will be generated automatically from the class name.
idxIndex of the data file. Negative value means no index.

Definition at line 29 of file CMat.cpp.

Here is the call graph for this function:

◆ reset()

void DirectGraphicalModels::CCMat::reset ( void  )

Resets class variables.

Allows to re-use the class.

Definition at line 19 of file CMat.cpp.

Here is the call graph for this function:

◆ save()

void DirectGraphicalModels::CCMat::save ( const std::string &  path,
const std::string &  name = std::string(),
short  idx = -1 
) const

Saves the confusion matrix.

Allows to re-use the class. Stores data to the file: "<path><name>_<idx>.dat".

Parameters
pathPath to the destination folder.
nameName of data file. If empty, will be generated automatically from the class name.
idxIndex of the destination file. Negative value means no index.

Definition at line 24 of file CMat.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ m_pConfusionMatrix

CPriorEdge* DirectGraphicalModels::CCMat::m_pConfusionMatrix
private

COnfusion matrix container.

Definition at line 84 of file CMat.h.


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