3#include "../_cexports/c_polimago.h"
5#include "../global.hpp"
6#include "../string.hpp"
7#include "test_result_base.hpp"
26 class ClassificationTestResult :
public TestResultBase
29 explicit ClassificationTestResult(ReleaseObjectGuard &&guard)
33 for (
decltype(numClasses) i = 0; i < numClasses; ++i)
36 CVB_CALL_CAPI_CHECKED(PMGetTestResultClassLabelTyped(
Handle(), i, lbl.data()));
37 classes_.push_back(lbl.data());
41 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
43 auto confidence = CVB_CALL_CAPI(PMGetTestResultConfidence(
Handle(), i));
44 exampleConfidences_.push_back(confidence);
47 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
50 for (
decltype(numClasses) j = 0; j < numClasses; ++j)
52 auto confidenceDistributionValue = CVB_CALL_CAPI(PMGetTestResultConfidenceDistribution(
Handle(), i, j));
53 confidenceDistribution.push_back(confidenceDistributionValue);
55 exampleConfidenceDistributions_.push_back(confidenceDistribution);
58 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
60 auto index = CVB_CALL_CAPI(PMGetTestResultTrueClassIndex(
Handle(), i));
61 trueClassIndices_.push_back(index);
64 for (
decltype(numExamples) i = 0; i < numExamples; ++i)
66 auto index = CVB_CALL_CAPI(PMGetTestResultPredictedClass(
Handle(), i));
67 predictedClassIndices_.push_back(index);
73 return thisObjectName_;
83 : ClassificationTestResult(ReleaseObjectGuard(LoadInternal(fileName)))
116 return std::make_unique<ClassificationTestResult>(fileName);
126 return static_cast<int>(CVB_CALL_CAPI(PMGetTestResultNumClasses(
Handle())));
138 return static_cast<int>(CVB_CALL_CAPI(PMGetTestResultOutputDimension(
Handle())));
148 return static_cast<int>(CVB_CALL_CAPI(PMGetTestResultNumErrors(
Handle())));
158 return static_cast<int>(CVB_CALL_CAPI(PMGetTestResultErrorRate(
Handle())));
178 return exampleConfidences_;
188 return exampleConfidenceDistributions_;
198 return trueClassIndices_;
208 return predictedClassIndices_;
217 const std::string thisObjectName_ =
"Polimago Classification Test Resul";
26 class ClassificationTestResult :
public TestResultBase {
…};
void * Handle() const noexcept
Classic API Polimago handle.
Definition predictor_base.hpp:68
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:124
std::vector< double > ExampleConfidences() const
Confidences in the classification decision for each sample.
Definition classification_test_result.hpp:176
static std::unique_ptr< ClassificationTestResult > Load(const String &fileName)
Load a saved test result from a file.
Definition classification_test_result.hpp:114
int NumErrors() const
Total number of errors made during classification testing.
Definition classification_test_result.hpp:146
double ErrorRate() const
Total number of errors divided by the total number of examples.
Definition classification_test_result.hpp:156
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:136
std::vector< std::vector< double > > ExampleConfidenceDistributions() const
Confidence distributions for each example.
Definition classification_test_result.hpp:186
std::vector< String > Classes() const
Class labels available in this test result.
Definition classification_test_result.hpp:166
std::vector< int > TrueClassIndices() const
The real class index for each example.
Definition classification_test_result.hpp:196
std::vector< int > PredictedClassIndices() const
Prediction results for all indices.
Definition classification_test_result.hpp:206
ClassificationTestResult(const String &fileName)
Load a saved classification test result from a file.
Definition classification_test_result.hpp:82
static std::unique_ptr< ClassificationTestResult > FromHandle(ReleaseObjectGuard &&guard)
Creates test result from a classic API handle.
Definition classification_test_result.hpp:99
int NumExamples() const
Number of examples that contributed to this test result.
Definition test_result_base.hpp:61
Namespace for the Polimago package testing functionality.
Definition classification_test_result.hpp:21
std::shared_ptr< ClassificationTestResult > ClassificationTestResultPtr
Convenience shared pointer for ClassificationTestResult.
Definition classification_test_result.hpp:221
Namespace for the Polimago package.
Definition classification_predictor.hpp:38
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49