OpenNN  2.2
Open Neural Networks Library
model_selection.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* M O D E L S E L E C T I O N C L A S S H E A D E R */
7 /* */
8 /* Roberto Lopez */
9 /* Artelnics - Making intelligent use of data */
11 /* */
12 /****************************************************************************************************************/
13 
14 #ifndef __MODELSELECTION_H__
15 #define __MODELSELECTION_H__
16 
17 // System includes
18 
19 #include <iostream>
20 #include <fstream>
21 #include <string>
22 #include <sstream>
23 #include <cmath>
24 #include <ctime>
25 
26 // OpenNN includes
27 
28 #include "vector.h"
29 #include "matrix.h"
30 
31 #include "performance_functional.h"
32 
33 #include "training_strategy.h"
34 
35 // TinyXml includes
36 
37 #include "../tinyxml2/tinyxml2.h"
38 
39 namespace OpenNN
40 {
41 
44 
46 {
47 
48 public:
49 
50  // DEFAULT CONSTRUCTOR
51 
52  explicit ModelSelection(void);
53 
54  // TRAINING STRATEGY CONSTRUCTOR
55 
57 
58  // FILE CONSTRUCTOR
59 
60  explicit ModelSelection(const std::string&);
61 
62  // XML CONSTRUCTOR
63 
64  explicit ModelSelection(const tinyxml2::XMLDocument&);
65 
66 
67  // DESTRUCTOR
68 
69  virtual ~ModelSelection(void);
70 
71 
72  // ENUMERATIONS
73 
75 
76  enum InputsSelectionMethod{MaximumLinearCorrelation, MaximumLogisticCorrelation, Exhaustive};
77 
78 
79  // STRUCTURES
80 
84 
86  {
88 
90 
92 
94 
96 
98 
100 
102 
104 
106 
108 
110  };
111 
112  // METHODS
113 
114  // Get methods
115 
117 
119  const size_t& get_parameters_assays_number(void) const;
120 
121  const bool& get_reserve_parameters_data(void) const;
122  const bool& get_reserve_performance_data(void) const;
123  const bool& get_reserve_generalization_performance_data(void) const;
124  const bool& get_reserve_minimal_parameters(void) const;
125  const bool& get_reserve_performance_data_statistics(void) const;
127  const bool& get_reserve_model_order_selection_plot(void) const;
128 
130 
131  const bool& get_display(void) const;
132 
133  // Set methods
134 
136 
137  void set_default(void);
138 
140  void set_parameters_assays_number(const size_t&);
141 
142  void set_assays_numbers(const size_t&, const size_t&);
143 
144  void set_reserve_parameters_data(const bool&);
145  void set_reserve_performance_data(const bool&);
147  void set_reserve_minimal_parameters(const bool&);
148  void set_reserve_performance_data_statistics(const bool&);
150  void set_reserve_model_order_selection_plot(const bool&);
151 
153 
154  void set_display(const bool&);
155 
156  // Correlation methods
157 
160 
161  // Model order selection methods
162 
163  void check(void) const;
164 
167  void perform_exhaustive_inputs_selection(void) const;
168 
169  void perform_inputs_selection(void) const;
170 
172 
174 
175  // Serialization methods
176 
177  tinyxml2::XMLDocument* to_XML(void) const;
178  void from_XML(const tinyxml2::XMLDocument&);
179 
180  void print(void) const;
181  void save(const std::string&) const;
182  void load(const std::string&);
183 
184 private:
185 
186  // MEMBERS
187 
189 
191 
193 
195 
197 
199 
201 
203 
204  // Model selection results
205 
207 
209 
211 
213 
215 
217 
219 
221 
223 
225 
227 
229 
231 
233 
235 
237 
239 
241 
243 
244  bool display;
245 };
246 
247 }
248 
249 #endif
250 
251 // OpenNN: Open Neural Networks Library.
252 // Copyright (c) 2005-2015 Roberto Lopez.
253 //
254 // This library is free software; you can redistribute it and/or
255 // modify it under the terms of the GNU Lesser General Public
256 // License as published by the Free Software Foundation; either
257 // version 2.1 of the License, or any later version.
258 //
259 // This library is distributed in the hope that it will be useful,
260 // but WITHOUT ANY WARRANTY; without even the implied warranty of
261 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
262 // Lesser General Public License for more details.
263 
264 // You should have received a copy of the GNU Lesser General Public
265 // License along with this library; if not, write to the Free Software
266 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
const bool & get_reserve_performance_data(void) const
Returns true if the performance functional performances are to be reserved, and false otherwise...
Vector< Vector< size_t > > inputs_indices
Indices for selecting the input variables.
void from_XML(const tinyxml2::XMLDocument &)
const Vector< size_t > & get_hidden_perceptrons_numbers(void) const
Returns the complexities of the neural networks given by the numbers of hidden perceptrons.
InputsSelectionMethod
Enumeration of available methods for inputs selection.
const InputsSelectionMethod & get_inputs_selection_method(void) const
Returns the method for selecting those inputs which have more impact on the targets.
Matrix< double > generalization_performance_data
Generalization performance of the different neural networks.
void perform_maximum_linear_correlation_inputs_selection(void) const
void set_assays_numbers(const size_t &, const size_t &)
ModelSelectionResults perform_model_selection(void) const
bool reserve_generalization_performance_data
True if the generalization performance of all neural networks are to be reserved. ...
const bool & get_reserve_performance_data_statistics(void) const
Returns true if the statistics of the performance data are to be inclued in the model selection resul...
void perform_maximum_logistic_correlation_inputs_selection(void) const
TrainingStrategy * get_training_strategy_pointer(void) const
Returns a pointer to the training strategy object.
bool reserve_minimal_parameters
True if the vector parameters of the neural network presenting minimum generalization performance is ...
size_t parameters_assays_number
Number of trials for each neural network.
void set_reserve_generalization_performance_data_statistics(const bool &)
const bool & get_reserve_model_order_selection_plot(void) const
Returns true if the necessary data for plotting the model selection results is to be included in the ...
const size_t & get_parameters_assays_number(void) const
Returns the number of trials for each network architecture.
Vector< Vector< double > > performance_data_statistics
Statistics of the performance functional performance for the different neural networks.
const bool & get_reserve_generalization_performance_data(void) const
Returns true if the performance functional generalization performances are to be reserved, and false otherwise.
bool display
Display messages to screen.
void set_reserve_model_order_selection_plot(const bool &)
Vector< Vector< double > > generalization_performance_data_statistics
Statistics of the generalization performance for the different neural networks.
void load(const std::string &)
const bool & get_reserve_parameters_data(void) const
Returns true if the neural network parameters are to be reserved, and false otherwise.
bool reserve_parameters_data
True if the parameters of all neural networks are to be reserved.
void set_inputs_selection_method(const InputsSelectionMethod &)
void check(void) const
Checks that the different pointers needed for performing the model selection are not NULL...
void set_reserve_performance_data(const bool &)
void set_reserve_parameters_data(const bool &)
void set_reserve_performance_data_statistics(const bool &)
void perform_inputs_selection(void) const
void perform_exhaustive_inputs_selection(void) const
double correlation_goal
Goal value for a single input-target correlation.
bool reserve_performance_data
True if the performance of all neural networks are to be reserved.
const bool & get_reserve_generalization_performance_data_statistics(void) const
Returns true if the statistics of the generalization performance data are to be inclued in the model ...
Vector< double > minimal_parameters
Vector of parameters for the neural network with minimum generalization performance.
bool reserve_performance_data_statistics
True if the statistics of the different performances are to be reserved.
bool reserve_model_order_selection_plot
True if the data needed to plot the results from the model selection plot is to be reserved...
Matrix< Vector< double > > parameters_data
Parameters of the different neural networks.
void set_training_strategy_pointer(TrainingStrategy *)
Matrix< double > performance_data
Performance performance of the different neural networks.
ModelSelection(void)
Default constructor.
ModelSelectionResults perform_order_selection(void) const
tinyxml2::XMLDocument * to_XML(void) const
TrainingStrategy * training_strategy_pointer
Pointer to a training strategy object.
virtual ~ModelSelection(void)
Destructor.
Matrix< double > calculate_linear_correlations(void) const
void save(const std::string &) const
void set_parameters_assays_number(const size_t &)
Matrix< double > calculate_logistic_correlations(void) const
const bool & get_display(void) const
void set_reserve_minimal_parameters(const bool &)
void print(void) const
Prints to the screen the XML representation of this model selection object.
void set_display(const bool &)
void set_reserve_generalization_performance_data(const bool &)
InputsSelectionMethod inputs_selection_method
Inputs selection method variable.
bool reserve_generalization_performance_data_statistics
True if the statistics of the different generalization performances are to be reserved.
const bool & get_reserve_minimal_parameters(void) const
Returns true if the parameters vector of the neural network with minimum performance functional perfo...
Vector< size_t > hidden_perceptrons_numbers
Complexities for selecting the network architecture.
void set_hidden_perceptrons_numbers(const Vector< size_t > &)