STK++ 0.9.13
STK::Stat::ConfusionMatrix< TrueArray, PredArray > Class Template Reference

Class computing the confusion matrix given two vectors of integer. More...

#include <STK_Stat_ConfusionMatrix.h>

Public Member Functions

 ConfusionMatrix (TrueArray const &trueClass, PredArray const &predictClass)
 default constructor
 
CSquareXi operator() ()
 

Protected Attributes

TrueArray consttrueClass_
 
PredArray constpredictClass_
 

Detailed Description

template<class TrueArray, class PredArray>
class STK::Stat::ConfusionMatrix< TrueArray, PredArray >

Class computing the confusion matrix given two vectors of integer.

Definition at line 50 of file STK_Stat_ConfusionMatrix.h.

Constructor & Destructor Documentation

◆ ConfusionMatrix()

STK::Stat::ConfusionMatrix< TrueArray, PredArray >::ConfusionMatrix ( TrueArray const trueClass,
PredArray const predictClass 
)
inline

default constructor

Definition at line 54 of file STK_Stat_ConfusionMatrix.h.

55 : trueClass_(trueClass), predictClass_(predictClass)
56 {
59 if (trueClass_.range() != predictClass_.range())
60 { STKRUNTIME_ERROR_NO_ARG(confusionMatrix(trueClass,predictClass),trueClass and predictClass are not of the same size);}
61 }
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
CSquareXi confusionMatrix(TrueArray const &trueClass, PredArray const &predictClass)
Utility function computing the confusion matrix given two vectors of integer.

References STK::Stat::confusionMatrix(), STK::Stat::ConfusionMatrix< TrueArray, PredArray >::predictClass_, STK_STATIC_ASSERT_ONE_DIMENSION_ONLY, STKRUNTIME_ERROR_NO_ARG, and STK::Stat::ConfusionMatrix< TrueArray, PredArray >::trueClass_.

Member Function Documentation

◆ operator()()

Returns
the confusion matrix obtained with the true classes and the predicted classes.

Definition at line 66 of file STK_Stat_ConfusionMatrix.h.

67 {
68 // compute nbLevels and create result
69 int min = std::min(trueClass_.minElt(), predictClass_.minElt());
70 int max = std::max(trueClass_.maxElt(), predictClass_.maxElt());
71 CSquareXi res(Range(min, max, 0), 0);
72 for (int i=trueClass_.begin(); i<trueClass_.end(); ++i)
73 { res(trueClass_[i], predictClass_[i])++;}
74 return res;
75 }
hidden::FunctorTraits< Derived, MaxOp >::Row max(Derived const &A)
Compute the maximal(s) value(s) of A.
hidden::FunctorTraits< Derived, MinOp >::Row min(Derived const &A)
Compute the minimal(s) value(s) of A.
CArraySquare< int, UnknownSize, Arrays::by_col_ > CSquareXi
TRange< UnknownSize > Range
Definition STK_Range.h:59

References STK::Stat::max(), STK::Stat::min(), STK::Stat::ConfusionMatrix< TrueArray, PredArray >::predictClass_, and STK::Stat::ConfusionMatrix< TrueArray, PredArray >::trueClass_.

Member Data Documentation

◆ predictClass_

◆ trueClass_


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