Vita
gp/src/search.h
Go to the documentation of this file.
1
13#if !defined(VITA_SRC_SEARCH_H)
14#define VITA_SRC_SEARCH_H
15
16#include "kernel/vitafwd.h"
17#include "kernel/gp/src/dss.h"
21#include "kernel/gp/team.h"
22#include "kernel/search.h"
23
24namespace vita
25{
26enum class evaluator_id
27{
28 count = 0, mae, rmae, mse, bin, dyn_slot, gaussian, undefined
29};
30enum class validator_id
31{
32 as_is, dss, holdout, undefined
33};
34
35enum class metric_flags : unsigned
36{
37 nothing = 0x0000,
38
39 accuracy = 1 << 0,
40 f1_score = 1 << 1,
41
42 everything = 0xFFFF
43};
44
52template<class T = i_mep, template<class> class ES = std_es>
53class src_search final : public search<T, ES>
54{
55public:
56 using individual_type = T;
57
58 explicit src_search(src_problem &, metric_flags = metric_flags::nothing);
59
60 std::unique_ptr<basic_src_lambda_f> lambdify(const T &) const;
61
62 src_search &evaluator(evaluator_id, const std::string & = "");
63 src_search &validation_strategy(validator_id);
64
65 bool is_valid() const override;
66
67protected:
68 // *** Template methods / customization points ***
69 void after_evolution(const summary<T> &) override;
70
71 void calculate_metrics(summary<T> *) const override;
72
73 // Requires the availability of a validation function and of validation data.
74 bool can_validate() const override;
75
76 void log_stats(const search_stats<T> &,
77 tinyxml2::XMLDocument *) const override;
78
79 void print_resume(const model_measurements &) const override;
80
81 void tune_parameters() override;
82
83private:
84 dataframe &training_data() const;
85 dataframe &test_data() const;
86 dataframe &validation_data() const;
87 src_problem &prob() const;
88 template<class E, class... Args> void set_evaluator(Args && ...);
89 bool stop_condition(const summary<T> &) const;
90
91 // *** Private data members ***
92 // Preferred evaluator for symbolic regression.
93 evaluator_id p_symre;
94
95 // Preferred evaluator for classification.
96 evaluator_id p_class;
97
98 // Metrics we have to calculate during the search.
99 metric_flags metrics;
100};
101
102#include "kernel/gp/src/search.tcc"
103
104} // namespace vita
105
106#endif // include guard
A 2-dimensional labeled data structure with columns of potentially different types.
Definition: dataframe.h:48
Calculates the fitness of an individual.
Definition: evaluator.h:54
Search drives the evolution.
Definition: search.h:54
Provides a GP-specific interface to the generic problem class.
Drives the search for solutions of symbolic regression / classification tasks.
Definition: gp/src/search.h:54
A summary of evolution (results, statistics...).
Interface for specific training / cross validation techniques (e.g.
The main namespace for the project.
A collection of measurements.