Skip to content
Snippets Groups Projects
Commit 4bfb368f authored by Julien Malik's avatar Julien Malik
Browse files

ENH: add correspondence from index to classlabel in ConfusionMatrixCalculator

parent 71e7d249
Branches
Tags
No related merge requests found
......@@ -97,11 +97,22 @@ public:
itkGetMacro(NumberOfSamples, unsigned long);
itkGetMacro(ConfusionMatrix, ConfusionMatrixType);
/* Gives the correspondence between a class label
* and its index in the confusion matrix
*/
std::map<ClassLabelType, int> GetMapOfClasses() const
{
return m_MapOfClasses;
}
/* Gives the correspondence between an index in the
* confusion matrix and the class label
*/
std::map<int, ClassLabelType> GetMapOfIndices() const
{
return m_MapOfIndices;
}
protected:
ConfusionMatrixCalculator();
virtual ~ConfusionMatrixCalculator() {}
......@@ -136,6 +147,7 @@ private:
double m_FScore;
std::map<ClassLabelType, int> m_MapOfClasses;
std::map<int, ClassLabelType> m_MapOfIndices;
unsigned short m_NumberOfClasses;
unsigned long m_NumberOfSamples;
......
......@@ -77,15 +77,14 @@ ConfusionMatrixCalculator<TRefListLabel, TProdListLabel>
int countClasses = 0;
while (refIterator != m_ReferenceLabels->End())
{
int currentLabel = refIterator.GetMeasurementVector()[0];
if (m_MapOfClasses.find(currentLabel) == m_MapOfClasses.end())
{
m_MapOfClasses[currentLabel] = countClasses;
m_MapOfIndices[countClasses] = currentLabel;
++countClasses;
}
++refIterator;
}
m_NumberOfClasses = countClasses;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment