/usr/include/OTB-5.8/otbConfusionMatrixMeasurements.h is in libotb-dev 5.8.0+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | /*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef otbConfusionMatrixMeasurements_h
#define otbConfusionMatrixMeasurements_h
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkVariableSizeMatrix.h"
#include "itkVariableLengthVector.h"
namespace otb
{
/** \class ConfusionMatrixMeasurements
* This class computes measurements on the input confusion matrix.
*
* For a 2 classes problem, the confusion matrix is organized as follows:
* \f[ \left( \begin{array}{cc} True Positives & False Negatives \\ False Positives & True Negatives \end{array} \right) \f]
*
* 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).
*
* 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:
* \f[ precision = \frac{TP}{\left( TP + FP \right) } \f]
* \f[ recall = \frac{TP}{\left( TP + FN \right) } \f]
* \f[ FScore = \frac{2 * precision * recall}{\left( precision + recall \right) } \f]
*
* Moreover overall accuracy and \f[ \kappa \f] index are computed.
*
*
* \ingroup OTBSupervised
*/
template <class TConfusionMatrix = itk::VariableSizeMatrix<unsigned long>, class TLabel = int >
class ITK_EXPORT ConfusionMatrixMeasurements :
public itk::Object
{
public:
/** Standard class typedefs */
typedef ConfusionMatrixMeasurements Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(ConfusionMatrixMeasurements, itk::Object);
/** Method for creation through the object factory. */
itkNewMacro(Self);
typedef TLabel ClassLabelType;
typedef std::map<ClassLabelType, int> MapOfClassesType;
typedef std::map<int, ClassLabelType> MapOfIndicesType;
/** Type for the confusion matrix */
typedef TConfusionMatrix ConfusionMatrixType;
/** Type for the measurement */
typedef itk::VariableLengthVector<double> MeasurementType;
/** Computes the measurements over m_ConfusionMatrix. */
void Compute(void);
/** Accessors */
itkSetMacro(ConfusionMatrix, ConfusionMatrixType);
itkGetMacro(TruePositiveValues, MeasurementType);
itkGetMacro(TrueNegativeValues, MeasurementType);
itkGetMacro(FalsePositiveValues, MeasurementType);
itkGetMacro(FalseNegativeValues, MeasurementType);
itkGetMacro(TruePositiveValue, double);
itkGetMacro(TrueNegativeValue, double);
itkGetMacro(FalsePositiveValue, double);
itkGetMacro(FalseNegativeValue, double);
itkGetMacro(KappaIndex, double);
itkGetMacro(OverallAccuracy, double);
itkGetMacro(Precisions, MeasurementType);
itkGetMacro(Recalls, MeasurementType);
itkGetMacro(FScores, MeasurementType);
itkGetMacro(Precision, double);
itkGetMacro(Recall, double);
itkGetMacro(FScore, double);
itkGetMacro(NumberOfClasses, unsigned short);
itkGetMacro(NumberOfSamples, unsigned long);
/* Gives the correspondence between a class label
* and its index in the confusion matrix
*/
virtual void SetMapOfClasses(const MapOfClassesType _arg)
{
m_MapOfClasses = _arg;
typename MapOfClassesType::iterator itMapOfClasses;
m_MapOfIndices.clear();
for (itMapOfClasses = m_MapOfClasses.begin(); itMapOfClasses != m_MapOfClasses.end(); ++itMapOfClasses)
{
m_MapOfIndices[itMapOfClasses->second] = itMapOfClasses->first;
}
}
MapOfClassesType GetMapOfClasses() const
{
return m_MapOfClasses;
}
/* Gives the correspondence between an index in the
* confusion matrix and the class label
*/
virtual void SetMapOfIndices(const MapOfIndicesType _arg)
{
m_MapOfIndices = _arg;
typename MapOfIndicesType::iterator itMapOfIndices;
m_MapOfClasses.clear();
for (itMapOfIndices = m_MapOfIndices.begin(); itMapOfIndices != m_MapOfIndices.end(); ++itMapOfIndices)
{
m_MapOfClasses[itMapOfIndices->second] = itMapOfIndices->first;
}
}
MapOfIndicesType GetMapOfIndices() const
{
return m_MapOfIndices;
}
protected:
ConfusionMatrixMeasurements();
~ConfusionMatrixMeasurements() ITK_OVERRIDE {}
//void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
ConfusionMatrixMeasurements(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
double m_KappaIndex;
double m_OverallAccuracy;
MeasurementType m_FalseNegativeValues;
MeasurementType m_TrueNegativeValues;
MeasurementType m_FalsePositiveValues;
MeasurementType m_TruePositiveValues;
MeasurementType m_Precisions;
MeasurementType m_Recalls;
MeasurementType m_FScores;
double m_FalseNegativeValue;
double m_TrueNegativeValue;
double m_FalsePositiveValue;
double m_TruePositiveValue;
double m_Precision;
double m_Recall;
double m_FScore;
MapOfClassesType m_MapOfClasses;
MapOfIndicesType m_MapOfIndices;
unsigned short m_NumberOfClasses;
unsigned long m_NumberOfSamples;
ConfusionMatrixType m_ConfusionMatrix;
};
} // end of namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbConfusionMatrixMeasurements.txx"
#endif
#endif
|