3#include "../_cexports/c_polimago.h"
5#include "../global.hpp"
6#include "../string.hpp"
7#include "test_result_base.hpp"
33 for (
decltype(numClasses) i = 0; i < numClasses; ++i)
35 const int classPredClassMaxLen = 256;
36 Char lbl[classPredClassMaxLen];
37 CVB_CALL_CAPI_CHECKED(PMGetTestResultClassLabelTyped(
Handle(), i, lbl));
38 classes_.push_back (lbl);
42 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
44 auto confidence = CVB_CALL_CAPI(PMGetTestResultConfidence(
Handle(), i));
45 exampleConfidences_.push_back (confidence);
48 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
51 for (
decltype(numClasses) j = 0; j < numClasses; ++j)
53 auto confidenceDistributionValue = CVB_CALL_CAPI(PMGetTestResultConfidenceDistribution(
Handle(), i, j));
54 confidenceDistribution.push_back (confidenceDistributionValue);
56 exampleConfidenceDistributions_.push_back (confidenceDistribution);
59 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
61 auto index = CVB_CALL_CAPI(PMGetTestResultTrueClassIndex(
Handle(), i));
62 trueClassIndices_.push_back (index);
65 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
67 auto index = CVB_CALL_CAPI(PMGetTestResultPredictedClass(
Handle(), i));
68 predictedClassIndices_.push_back (index);
74 return thisObjectName_;
111 if (!guard.Handle ())
136 return static_cast<int>(CVB_CALL_CAPI (PMGetTestResultNumClasses(
Handle())));
146 return static_cast<int>(CVB_CALL_CAPI (PMGetTestResultOutputDimension(
Handle())));
156 return static_cast<int>(CVB_CALL_CAPI (PMGetTestResultNumErrors(
Handle())));
166 return static_cast<int>(CVB_CALL_CAPI (PMGetTestResultErrorRate(
Handle())));
186 return exampleConfidences_;
196 return exampleConfidenceDistributions_;
206 return trueClassIndices_;
216 return predictedClassIndices_;
225 const std::string thisObjectName_ =
"Polimago Classification Test Resul";
void * Handle() const noexcept
Classic API Polimago handle.
Definition: predictor_base.hpp:66
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
static std::unique_ptr< ClassificationTestResult > Load(const String &fileName)
Load a saved test result from a file.
Definition: classification_test_result.hpp:124
int NumErrors() const
Total number of errors made during classification testing.
Definition: classification_test_result.hpp:154
double ErrorRate() const
Total number of errors divided by the total number of examples.
Definition: classification_test_result.hpp:164
int OutputDimension() const
For tests with usage OneVersusAll the output dimension will equal the number of classes in the traini...
Definition: classification_test_result.hpp:144
std::vector< std::vector< double > > ExampleConfidenceDistributions() const
Confidence distributions for each example.
Definition: classification_test_result.hpp:194
std::vector< String > Classes() const
Class labels available in this test result.
Definition: classification_test_result.hpp:174
std::vector< int > TrueClassIndices() const
The real class index for each example.
Definition: classification_test_result.hpp:204
ClassificationTestResult(ClassificationTestResult &&) noexcept=default
Move constructor.
std::vector< int > PredictedClassIndices() const
Prediction results for all indices.
Definition: classification_test_result.hpp:214
ClassificationTestResult(const String &fileName)
Load a saved classification test result from a file.
Definition: classification_test_result.hpp:84
static std::unique_ptr< ClassificationTestResult > FromHandle(ReleaseObjectGuard &&guard)
Creates test result from a classic API handle.
Definition: classification_test_result.hpp:109
Base class for all Polimago Test Results.
Definition: test_result_base.hpp:26
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
char Char
Character type for wide characters or unicode characters.
Definition: string.hpp:59