3#include "../_cexports/c_polimago.h"
5#include "../global.hpp"
6#include "classification_test_result.hpp"
65 return confidenceDistribution_;
90 BuildConfusionMatrix (res);
91 UpdateVisibleMatrix ();
104 if (classIndex >= numClasses)
110 for (
decltype(numClasses) c = 0; c < numClasses; ++c)
112 sum +=
static_cast<int>(indexArray_[classIndex][c].size());
126 for (
decltype(numClasses) i = 0; i < numClasses; ++i)
142 if (classIndex >= numClasses)
146 return static_cast<int> (
At (classIndex, classIndex).size());
158 for (
decltype(numClasses) i = 0; i < numClasses; ++i)
174 if (classIndex >= numClasses)
180 for (
decltype(numClasses) c = 0; c < numClasses; ++c)
182 sum +=
static_cast<int>(indexArray_[classIndex][c].size());
185 sum +=
static_cast<int> (
At (classIndex, c).size());
200 for (
decltype(numClasses) i = 0; i < numClasses; ++i)
215 for (
auto && r : rejects_)
217 retval +=
static_cast<int>(r.size());
230 if (classIndex >= rejects_.size())
235 return rejects_[classIndex];
245 return static_cast<int>(indexArray_.size());
275 return visibleArray_[trueClass][predictedClass];
285 return confidenceThreshold_;
298 if ((threshold < 0.0) || (threshold > 1.5))
300 throw std::out_of_range (
"confidence threshold value must be within <0.0, 1.5>");
302 confidenceThreshold_ = threshold;
303 UpdateVisibleMatrix();
311 rejects_.resize (numClasses);
313 indexArray_.resize (numClasses);
314 for (
auto && indexRow : indexArray_)
316 indexRow.resize (numClasses);
319 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
327 void UpdateVisibleMatrix ()
329 for (
auto && r : rejects_)
336 visibleArray_ = indexArray_;
340 visibleArray_.resize (indexArray_.size());
341 for (
auto && visibleRow : visibleArray_)
343 visibleRow.resize (indexArray_[0].size());
345 for (
size_t x = 0; x < visibleArray_.size (); ++x)
347 visibleArray_[x].resize (indexArray_[x].size());
348 for (
size_t y = 0; y < visibleArray_[x].size (); ++y)
350 for (
auto && e : indexArray_[x][y])
354 visibleArray_[x][y].push_back (e);
358 rejects_[x].push_back (e);
369 double confidenceThreshold_ = 0.0;
375using Testing::PredictionResult;
376using Testing::ConfusionMatrix;
Classification test result object.
Definition: classification_test_result.hpp:27
int NumClasses() const
Number of classes in the sample database on which the test result was calculated.
Definition: classification_test_result.hpp:134
std::vector< double > ExampleConfidences() const
Confidences in the classification decision for each sample.
Definition: classification_test_result.hpp:184
std::vector< std::vector< double > > ExampleConfidenceDistributions() const
Confidence distributions for each example.
Definition: classification_test_result.hpp:194
std::vector< int > TrueClassIndices() const
The real class index for each example.
Definition: classification_test_result.hpp:204
std::vector< int > PredictedClassIndices() const
Prediction results for all indices.
Definition: classification_test_result.hpp:214
Representation of a confusion matrix.
Definition: confusion_matrix.hpp:81
int TotalCorrect() const
Overall number of correctly classified samples.
Definition: confusion_matrix.hpp:154
void SetConfidenceThreshold(double threshold)
Set the threshold to be taken into account when determining the confusion matrix.
Definition: confusion_matrix.hpp:296
std::vector< PredictionResult > At(int trueClass, int predictedClass) const
Access the results stored in the confusion matrix.
Definition: confusion_matrix.hpp:268
std::vector< PredictionResult > Rejects(int classIndex) const
Get the rejects for a given class.
Definition: confusion_matrix.hpp:228
int NumClasses() const noexcept
Number of classes in this matrix.
Definition: confusion_matrix.hpp:243
int TotalErrors(int classIndex) const
Determine the total number of errors made for a given class.
Definition: confusion_matrix.hpp:171
int TotalSamples(int classIndex) const
Determine the total number of samples available for a given class.
Definition: confusion_matrix.hpp:101
int TotalRejects() const
Total number of rejected items (i.e. items that have a confidence of less than the currently set thre...
Definition: confusion_matrix.hpp:212
double ConfidenceThreshold() const noexcept
Get threshold to be taken into account when determining the confusion matrix.
Definition: confusion_matrix.hpp:283
int TotalSamples() const
Return the total sample count.
Definition: confusion_matrix.hpp:122
int TotalErrors() const
Determine the total error count.
Definition: confusion_matrix.hpp:196
int TotalCorrect(int classIndex) const
Number of correctly classified samples in a given class.
Definition: confusion_matrix.hpp:139
ConfusionMatrix(const ClassificationTestResult &res)
Constructor.
Definition: confusion_matrix.hpp:88
The information contained in each cell of the confusion matrix.
Definition: confusion_matrix.hpp:25
double Confidence() const noexcept
Confidence value of the (best) classification result.
Definition: confusion_matrix.hpp:53
int ExampleIndex() const noexcept
The index of the example (with refers to the index in the sample image list from which the test resul...
Definition: confusion_matrix.hpp:43
std::vector< double > ConfidenceDistribution() const
Distribution of confidences among the other known classes.
Definition: confusion_matrix.hpp:63
int NumExamples() const
Number of examples that contributed to this test result.
Definition: test_result_base.hpp:67
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24