OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
inputs_selection.h
Go to the documentation of this file.
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// I N P U T S S E L E C T I O N C L A S S H E A D E R
5//
6// Artificial Intelligence Techniques SL
7// artelnics@artelnics.com
8
9#pragma once
10
11#include "pch.h"
12
13namespace opennn
14{
15
17
18struct TrainingResults;
20
23{
24public:
25
34
37 virtual ~InputsSelection() = default;
38
40
42
43 bool get_display() const { return display; }
44
46 virtual Index get_minimum_inputs_number() const = 0;
47
49 virtual Index get_maximum_inputs_number() const = 0;
50
51 void set(TrainingStrategy* new_training_strategy) { training_strategy = new_training_strategy; }
52
53 void set_trials_number(const Index new_trials_number) { trials_number = new_trials_number; }
54
55 void set_display(bool new_display) { display = new_display; }
56
57 void set_validation_error_goal(const float new_validation_error_goal) { validation_error_goal = new_validation_error_goal; }
58 void set_maximum_epochs(const Index new_maximum_epochs) { maximum_epochs = new_maximum_epochs; }
59 void set_maximum_validation_failures(const Index new_maximum_validation_failures) { maximum_validation_failures = new_maximum_validation_failures; }
60 void set_maximum_time(const float new_maximum_time) { maximum_time = new_maximum_time; }
61
63 void check() const;
64
68
69 string get_name() const
70 {
71 return name;
72 }
73
75 virtual void from_JSON(const JsonDocument&) = 0;
76
78 virtual void to_JSON(JsonWriter&) const = 0;
79
81 void save(const filesystem::path&) const;
82
84 void load(const filesystem::path&);
85
87 virtual void print() const {}
88
89protected:
90
92
93 Index trials_number = 1;
94
95 bool display = true;
96
97 // Stopping criteria
98
100
102
104
106
107 string name;
108};
109
161
162}
163
164// OpenNN: Open Neural Networks Library.
165// Copyright(C) 2005-2026 Artificial Intelligence Techniques, SL.
166// Licensed under the GNU Lesser General Public License v2.1 or later.
bool display
Definition inputs_selection.h:95
void check() const
Verifies that the training strategy and its dependencies are valid for inputs selection.
virtual Index get_minimum_inputs_number() const =0
Returns the minimum number of input variables that the algorithm may select.
virtual Index get_maximum_inputs_number() const =0
Returns the maximum number of input variables that the algorithm may select.
void save(const filesystem::path &) const
Saves the algorithm configuration to disk.
void load(const filesystem::path &)
Loads the algorithm configuration from disk.
bool get_display() const
Definition inputs_selection.h:43
InputsSelection(TrainingStrategy *=nullptr)
Constructs the algorithm bound to an optional training strategy.
Index maximum_epochs
Definition inputs_selection.h:101
void set(TrainingStrategy *new_training_strategy)
Definition inputs_selection.h:51
virtual void to_JSON(JsonWriter &) const =0
Writes algorithm configuration to a JSON writer.
string name
Definition inputs_selection.h:107
string get_name() const
Definition inputs_selection.h:69
void set_display(bool new_display)
Definition inputs_selection.h:55
void set_maximum_time(const float new_maximum_time)
Definition inputs_selection.h:60
virtual InputsSelectionResults perform_input_selection()=0
Runs the inputs selection algorithm until a stopping criterion is met.
TrainingStrategy * training_strategy
Definition inputs_selection.h:91
void set_maximum_validation_failures(const Index new_maximum_validation_failures)
Definition inputs_selection.h:59
virtual void from_JSON(const JsonDocument &)=0
Loads algorithm configuration from a JSON document.
bool has_training_strategy() const
Definition inputs_selection.h:41
void set_maximum_epochs(const Index new_maximum_epochs)
Definition inputs_selection.h:58
void set_validation_error_goal(const float new_validation_error_goal)
Definition inputs_selection.h:57
void set_trials_number(const Index new_trials_number)
Definition inputs_selection.h:53
const TrainingStrategy * get_training_strategy() const
Definition inputs_selection.h:39
virtual void print() const
Prints a human-readable description of the algorithm to stdout.
Definition inputs_selection.h:87
virtual ~InputsSelection()=default
Index maximum_validation_failures
Definition inputs_selection.h:103
float validation_error_goal
Definition inputs_selection.h:99
StoppingCondition
Reasons the inputs selection loop may terminate.
Definition inputs_selection.h:27
@ MaximumInputs
Definition inputs_selection.h:30
@ SelectionErrorGoal
Definition inputs_selection.h:29
@ MaximumSelectionFailures
Definition inputs_selection.h:32
@ MaximumEpochs
Definition inputs_selection.h:31
@ MaximumTime
Definition inputs_selection.h:28
Index trials_number
Definition inputs_selection.h:93
float maximum_time
Definition inputs_selection.h:105
Definition json.h:72
Definition json.h:85
High-level orchestrator pairing a Loss with an Optimizer for a network/dataset.
Definition training_strategy.h:24
Definition adaptive_moment_estimation.h:14
constexpr float MAX
Definition pch.h:156
Matrix< float, Dynamic, 1 > VectorR
Definition pch.h:181
Matrix< bool, Dynamic, 1 > VectorB
Definition pch.h:183
Aggregated results of an inputs selection run including optimal inputs and error histories.
Definition inputs_selection.h:112
vector< Index > optimal_input_variables_indices
Definition inputs_selection.h:151
void print() const
Prints a summary of the selection results to stdout.
float optimum_training_error
Definition inputs_selection.h:145
VectorR mean_validation_error_history
Definition inputs_selection.h:141
VectorR training_error_history
Definition inputs_selection.h:137
VectorR optimal_parameters
Definition inputs_selection.h:133
string write_stopping_condition() const
Returns a human-readable string describing the stopping condition that ended the run.
InputsSelection::StoppingCondition stopping_condition
Definition inputs_selection.h:157
string elapsed_time
Definition inputs_selection.h:159
void set(const Index=0)
Resets the structure and reserves storage for the given number of epochs.
VectorR validation_error_history
Definition inputs_selection.h:139
VectorR mean_training_error_history
Definition inputs_selection.h:143
vector< string > optimal_input_variable_names
Definition inputs_selection.h:149
InputsSelectionResults(const Index=0)
Builds an empty results structure able to hold up to the given number of epochs.
float optimum_validation_error
Definition inputs_selection.h:147
void resize_history(const Index new_size)
Resizes the recorded error histories.
VectorB optimal_inputs
Definition inputs_selection.h:153
Index get_epochs_number() const
Returns the number of epochs actually recorded in the histories.
History and final metrics produced by a training run.
Definition optimizer.h:204