20 #ifndef _CONFUSIONMATRIX_H_
21 #define _CONFUSIONMATRIX_H_
25 #include "base/Vector2d.h"
26 #include "base/Optionpk.h"
35 short size()
const {
return m_results.size();};
36 void resize(
short nclass);
37 void setClassNames(
const std::vector<std::string>& classNames,
bool doSort=
false);
38 void pushBackClassName(
const std::string& className,
bool doSort=
false);
40 void setResult(
const std::string& theRef,
const std::string& theClass,
double theResult);
41 void incrementResult(
const std::string& theRef,
const std::string& theClass,
double theIncrement);
43 double nReference(
const std::string& theRef)
const;
44 double nReference()
const;
45 double nClassified(
const std::string& theRef)
const;
46 int nClasses()
const {
return m_classes.size();};
47 std::string getClass(
int iclass)
const {assert(iclass>=0);assert(iclass<m_classes.size());
return m_classes[iclass];};
48 int getClassIndex(std::string className)
const {
50 for(index=0;index<m_classes.size();++index){
51 if(m_classes[index]==className)
54 if(index>=m_classes.size())
64 std::vector<std::string> getClassNames()
const {
return m_classes;};
66 double pa(
const std::string& theClass,
double* se95=NULL)
const;
67 double ua(
const std::string& theClass,
double* se95=NULL)
const;
68 double oa(
double* se95=NULL)
const;
69 int pa_pct(
const std::string& theClass,
double* se95=NULL)
const;
70 int ua_pct(
const std::string& theClass,
double* se95=NULL)
const;
71 int oa_pct(
double* se95=NULL)
const;
79 void sortClassNames();
80 friend std::ostream& operator<<(std::ostream& os,
const ConfusionMatrix &cm){
81 for(
int iclass=0;iclass<cm.nClasses();++iclass)
82 os <<
"\t" << cm.m_classes[iclass];
84 assert(cm.m_classes.size()==cm.m_results.size());
85 for(
int irow=0;irow<cm.m_results.size();++irow){
86 os << cm.m_classes[irow];
87 for(
int icol=0;icol<cm.m_results[irow].size();++icol)
88 os <<
"\t" << cm.m_results[irow][icol];
94 std::vector<std::string> m_classes;