GEGELATI

Loading...
Searching...
No Matches
classificationSelectionMetrics.h
1
2
3#ifndef CLASSIFICATION_SELECTION_METRICS_H
4#define CLASSIFICATION_SELECTION_METRICS_H
5
6#include <numeric>
7
8#include "selector/selectionMetrics.h"
9
10namespace Selector {
18 class ClassificationSelectionMetrics : public SelectionMetrics
19 {
20 protected:
25 std::vector<double> scorePerClass;
26
31 std::vector<size_t> nbEvalPerClass;
32
33 public:
37 ClassificationSelectionMetrics() = default;
38
47 ClassificationSelectionMetrics(
48 const std::vector<double>& scorePerClass,
49 const std::vector<size_t>& nbEvalPerClass)
50 : SelectionMetrics(std::accumulate(scorePerClass.cbegin(),
51 scorePerClass.cend(), 0.0) /
52 scorePerClass.size()),
53 scorePerClass{scorePerClass}, nbEvalPerClass{nbEvalPerClass}
54 {
55 if (scorePerClass.size() != nbEvalPerClass.size()) {
56 throw std::runtime_error("Number of class missmatch.");
57 }
58 };
59
63 virtual const std::vector<double>& getScorePerClass() const;
64
68 virtual const std::vector<size_t>& getNbEvalPerClassPerClass() const;
69
73 void initMetrics(
74 const TPG::TPGVertex* agent,
75 const Learn::LearningEnvironment& learningEnvironment) override;
76
81 void extractMetricsEpisode(
82 const TPG::TPGVertex* agent, size_t nbStepsExecuted,
83 const Learn::LearningEnvironment& learningEnvironment) override;
84
89 virtual void weightedSum(std::shared_ptr<SelectionMetrics> other,
90 size_t nbEvaluation,
91 size_t nbEvaluationOther) override;
92 };
93
94}; // namespace Selector
95
96#endif // CLASSIFICATION_SELECTION_METRICS_H
Learn::LearningEnvironment
Interface for creating a Learning Environment.
Definition learningEnvironment.h:81
Selector::ClassificationSelectionMetrics
Class to extract metrics from either the agent or the environment.
Definition classificationSelectionMetrics.h:19
Selector::ClassificationSelectionMetrics::getNbEvalPerClassPerClass
virtual const std::vector< size_t > & getNbEvalPerClassPerClass() const
Definition classificationSelectionMetrics.cpp:62
Selector::ClassificationSelectionMetrics::ClassificationSelectionMetrics
ClassificationSelectionMetrics(const std::vector< double > &scorePerClass, const std::vector< size_t > &nbEvalPerClass)
Constructor with score and utility initialization.
Definition classificationSelectionMetrics.h:47
Selector::ClassificationSelectionMetrics::initMetrics
void initMetrics(const TPG::TPGVertex *agent, const Learn::LearningEnvironment &learningEnvironment) override
Specialization of the initialisation of the metrics.
Definition classificationSelectionMetrics.cpp:8
Selector::ClassificationSelectionMetrics::nbEvalPerClass
std::vector< size_t > nbEvalPerClass
Vector storing a size_t value per class representing the number of evaluation per class.
Definition classificationSelectionMetrics.h:31
Selector::ClassificationSelectionMetrics::ClassificationSelectionMetrics
ClassificationSelectionMetrics()=default
Default constructor.
Selector::ClassificationSelectionMetrics::getScorePerClass
virtual const std::vector< double > & getScorePerClass() const
Definition classificationSelectionMetrics.cpp:56
Selector::ClassificationSelectionMetrics::extractMetricsEpisode
void extractMetricsEpisode(const TPG::TPGVertex *agent, size_t nbStepsExecuted, const Learn::LearningEnvironment &learningEnvironment) override
Specialization of the extraction of the metrics at the end of an episode.
Definition classificationSelectionMetrics.cpp:16
Selector::ClassificationSelectionMetrics::scorePerClass
std::vector< double > scorePerClass
Vector storing a double score per class (i.e. per Action) of a classification LearningEnvironment.
Definition classificationSelectionMetrics.h:25
Selector::ClassificationSelectionMetrics::weightedSum
virtual void weightedSum(std::shared_ptr< SelectionMetrics > other, size_t nbEvaluation, size_t nbEvaluationOther) override
Specialization of weightedSum method to add the score per class and nbEvalPerClass.
Definition classificationSelectionMetrics.cpp:67
Selector::SelectionMetrics
Class to extract metrics from either the agent or the environment.
Definition selectionMetrics.h:18
TPG::TPGVertex
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
Selector
Definition mapElitesArchiveLogger.h:45