Orfeo ToolBox  4.2
Orfeo ToolBox is not a black box
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel > Class Template Reference

#include <otbConfusionMatrixCalculator.h>

+ Inheritance diagram for otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >:
+ Collaboration diagram for otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >:

Public Types

typedef
RefListLabelType::ValueType::ValueType 
ClassLabelType
 
typedef
otb::ConfusionMatrixMeasurements
< ConfusionMatrixType,
ClassLabelType
ConfusionMatrixMeasurementsType
 
typedef
itk::VariableSizeMatrix
< unsigned long > 
ConfusionMatrixType
 
typedef itk::SmartPointer
< const Self
ConstPointer
 
typedef std::map
< ClassLabelType, int > 
MapOfClassesType
 
typedef std::map< int,
ClassLabelType
MapOfIndicesType
 
typedef
itk::VariableLengthVector
< double > 
MeasurementType
 
typedef itk::SmartPointer< SelfPointer
 
typedef ProdListLabelType::Pointer ProdListLabelPointerType
 
typedef TProdListLabel ProdListLabelType
 
typedef RefListLabelType::Pointer RefListLabelPointerType
 
typedef TRefListLabel RefListLabelType
 
typedef ConfusionMatrixCalculator Self
 
typedef itk::Object Superclass
 

Public Member Functions

void Compute (void)
 
virtual ::itk::LightObject::Pointer CreateAnother (void) const
 
virtual ConfusionMatrixType GetConfusionMatrix ()
 
virtual double GetFalseNegativeValue ()
 
virtual MeasurementType GetFalseNegativeValues ()
 
virtual double GetFalsePositiveValue ()
 
virtual MeasurementType GetFalsePositiveValues ()
 
virtual double GetFScore ()
 
virtual MeasurementType GetFScores ()
 
virtual double GetKappaIndex ()
 
MapOfClassesType GetMapOfClasses () const
 
MapOfIndicesType GetMapOfIndices () const
 
virtual const char * GetNameOfClass () const
 
virtual unsigned short GetNumberOfClasses ()
 
virtual unsigned long GetNumberOfSamples ()
 
virtual double GetOverallAccuracy ()
 
virtual double GetPrecision ()
 
virtual MeasurementType GetPrecisions ()
 
virtual const ProdListLabelTypeGetProducedLabels ()
 
virtual double GetRecall ()
 
virtual MeasurementType GetRecalls ()
 
virtual const RefListLabelTypeGetReferenceLabels ()
 
virtual double GetTrueNegativeValue ()
 
virtual MeasurementType GetTrueNegativeValues ()
 
virtual double GetTruePositiveValue ()
 
virtual MeasurementType GetTruePositiveValues ()
 
 itkLegacyMacro (virtual void Update())
 
virtual void SetProducedLabels (ProdListLabelType *_arg)
 
virtual void SetReferenceLabels (RefListLabelType *_arg)
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 ConfusionMatrixCalculator ()
 
virtual ~ConfusionMatrixCalculator ()
 
void PrintSelf (std::ostream &os, itk::Indent indent) const
 

Private Member Functions

 ConfusionMatrixCalculator (const Self &)
 
void operator= (const Self &)
 

Private Attributes

ConfusionMatrixMeasurementsType::Pointer m_ConfMatMeasurements
 
ConfusionMatrixType m_ConfusionMatrix
 
double m_FalseNegativeValue
 
MeasurementType m_FalseNegativeValues
 
double m_FalsePositiveValue
 
MeasurementType m_FalsePositiveValues
 
double m_FScore
 
MeasurementType m_FScores
 
double m_KappaIndex
 
MapOfClassesType m_MapOfClasses
 
MapOfIndicesType m_MapOfIndices
 
unsigned short m_NumberOfClasses
 
unsigned long m_NumberOfSamples
 
double m_OverallAccuracy
 
double m_Precision
 
MeasurementType m_Precisions
 
ProdListLabelPointerType m_ProducedLabels
 
double m_Recall
 
MeasurementType m_Recalls
 
RefListLabelPointerType m_ReferenceLabels
 
double m_TrueNegativeValue
 
MeasurementType m_TrueNegativeValues
 
double m_TruePositiveValue
 
MeasurementType m_TruePositiveValues
 

Detailed Description

template<class TRefListLabel, class TProdListLabel>
class otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >

This class computes a confusion matrix from 2 lists of labels. It assumes that the 2 lists have the same length and uses the position of the labels in the lists to build the pairs reference/produced labels.

The rows and columns of the output confusion matrix are sorted according to increasing class labels.

For a 2 classes problem, the confusion matrix is organized as follows:

\[ \left( \begin{array}{cc} True Positives & False Negatives \\ False Positives & True Negatives \end{array} \right) \]

Please note that when accessing the confusion matrix values, the first index is the row index (reference samples), and the second is the column index (produced samples), so that accessing the false positive rate is done by calling GetConfusionMatrix()[1, 0] for the case of a 2 classes problem.

Some measurements are computed by this class: If we consider true positive (TP), true negative (TN), false positive (FP) and false negative (FP) rates, then in the 2 classes case:

\[ precision = \frac{TP}{\left( TP + FP \right) } \]

\[ recall = \frac{TP}{\left( TP + FN \right) } \]

\[ FScore = \frac{2 * precision * recall}{\left( precision + recall \right) } \]

In case of multiclasses problem, these measurements are extended by considering one class versus others.

Moreover overall accuracy and

\[ \kappa \]

index are computed.

Definition at line 56 of file otbConfusionMatrixCalculator.h.

Member Typedef Documentation

template<class TRefListLabel , class TProdListLabel >
typedef RefListLabelType::ValueType::ValueType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ClassLabelType

Definition at line 79 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef otb::ConfusionMatrixMeasurements<ConfusionMatrixType, ClassLabelType> otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ConfusionMatrixMeasurementsType

Type for the confusion matrix measurements calculator

Definition at line 87 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef itk::VariableSizeMatrix<unsigned long> otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ConfusionMatrixType

Type for the confusion matrix

Definition at line 84 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef itk::SmartPointer<const Self> otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ConstPointer

Definition at line 64 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef std::map<ClassLabelType, int> otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::MapOfClassesType

Definition at line 80 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef std::map<int, ClassLabelType> otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::MapOfIndicesType

Definition at line 81 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef itk::VariableLengthVector<double> otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::MeasurementType

Type for the measurement

Definition at line 90 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef itk::SmartPointer<Self> otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::Pointer

Definition at line 63 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef ProdListLabelType::Pointer otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ProdListLabelPointerType

Definition at line 77 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef TProdListLabel otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ProdListLabelType

Definition at line 76 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef RefListLabelType::Pointer otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::RefListLabelPointerType

Definition at line 74 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef TRefListLabel otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::RefListLabelType

List to store the corresponding labels

Definition at line 70 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef ConfusionMatrixCalculator otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::Self

Standard class typedefs

Definition at line 61 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
typedef itk::Object otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::Superclass

Definition at line 62 of file otbConfusionMatrixCalculator.h.

Constructor & Destructor Documentation

template<class TRefListLabel , class TProdListLabel >
otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ConfusionMatrixCalculator ( )
protected

Definition at line 26 of file otbConfusionMatrixCalculator.txx.

template<class TRefListLabel , class TProdListLabel >
virtual otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::~ConfusionMatrixCalculator ( )
inlineprotectedvirtual

Definition at line 144 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::ConfusionMatrixCalculator ( const Self )
private

Member Function Documentation

template<class TRefListLabel , class TProdListLabel >
void otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::Compute ( void  )

Computes m_ConfusionMatrix and then the measurements over it.

Definition at line 61 of file otbConfusionMatrixCalculator.txx.

References otbMsgDebugMacro.

template<class TRefListLabel , class TProdListLabel >
virtual::itk::LightObject::Pointer otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::CreateAnother ( void  ) const
template<class TRefListLabel , class TProdListLabel >
virtual ConfusionMatrixType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetConfusionMatrix ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetFalseNegativeValue ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetFalseNegativeValues ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetFalsePositiveValue ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetFalsePositiveValues ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetFScore ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetFScores ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetKappaIndex ( )
virtual
template<class TRefListLabel , class TProdListLabel >
MapOfClassesType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetMapOfClasses ( ) const
inline

Definition at line 129 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MapOfIndicesType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetMapOfIndices ( ) const
inline

Definition at line 137 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
virtual const char* otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

template<class TRefListLabel , class TProdListLabel >
virtual unsigned short otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetNumberOfClasses ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual unsigned long otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetNumberOfSamples ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetOverallAccuracy ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetPrecision ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetPrecisions ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual const ProdListLabelType* otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetProducedLabels ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetRecall ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetRecalls ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual const RefListLabelType* otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetReferenceLabels ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetTrueNegativeValue ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetTrueNegativeValues ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetTruePositiveValue ( )
virtual
template<class TRefListLabel , class TProdListLabel >
virtual MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::GetTruePositiveValues ( )
virtual
template<class TRefListLabel , class TProdListLabel >
otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::itkLegacyMacro ( virtual void   Update())
Deprecated:
in OTB 3.16, please use void Compute(void) instead.
template<class TRefListLabel , class TProdListLabel >
static Pointer otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::New ( )
static

Method for creation through the object factory.

template<class TRefListLabel , class TProdListLabel >
void otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::operator= ( const Self )
private
template<class TRefListLabel , class TProdListLabel >
void otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
protected

Definition at line 167 of file otbConfusionMatrixCalculator.txx.

template<class TRefListLabel , class TProdListLabel >
virtual void otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::SetProducedLabels ( ProdListLabelType _arg)
virtual
template<class TRefListLabel , class TProdListLabel >
virtual void otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::SetReferenceLabels ( RefListLabelType _arg)
virtual

Accessors

Member Data Documentation

template<class TRefListLabel , class TProdListLabel >
ConfusionMatrixMeasurementsType::Pointer otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_ConfMatMeasurements
private

Definition at line 180 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
ConfusionMatrixType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_ConfusionMatrix
private

Definition at line 179 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_FalseNegativeValue
private

Definition at line 164 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_FalseNegativeValues
private

Definition at line 155 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_FalsePositiveValue
private

Definition at line 166 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_FalsePositiveValues
private

Definition at line 157 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_FScore
private

Definition at line 171 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_FScores
private

Definition at line 162 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_KappaIndex
private

Definition at line 152 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MapOfClassesType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_MapOfClasses
private

Definition at line 173 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MapOfIndicesType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_MapOfIndices
private

Definition at line 174 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
unsigned short otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_NumberOfClasses
private

Definition at line 176 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
unsigned long otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_NumberOfSamples
private

Definition at line 177 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_OverallAccuracy
private

Definition at line 153 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_Precision
private

Definition at line 169 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_Precisions
private

Definition at line 160 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
ProdListLabelPointerType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_ProducedLabels
private

Definition at line 183 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_Recall
private

Definition at line 170 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_Recalls
private

Definition at line 161 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
RefListLabelPointerType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_ReferenceLabels
private

Definition at line 182 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_TrueNegativeValue
private

Definition at line 165 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_TrueNegativeValues
private

Definition at line 156 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
double otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_TruePositiveValue
private

Definition at line 167 of file otbConfusionMatrixCalculator.h.

template<class TRefListLabel , class TProdListLabel >
MeasurementType otb::ConfusionMatrixCalculator< TRefListLabel, TProdListLabel >::m_TruePositiveValues
private

Definition at line 158 of file otbConfusionMatrixCalculator.h.


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