00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* OpenNN: Open Neural Networks Library */ 00004 /* www.opennn.cimne.com */ 00005 /* */ 00006 /* 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 */ 00007 /* */ 00008 /* Roberto Lopez */ 00009 /* International Center for Numerical Methods in Engineering (CIMNE) */ 00010 /* Technical University of Catalonia (UPC) */ 00011 /* Barcelona, Spain */ 00012 /* E-mail: rlopez@cimne.upc.edu */ 00013 /* */ 00014 /****************************************************************************************************************/ 00015 00016 #ifndef __MODELSELECTION_H__ 00017 #define __MODELSELECTION_H__ 00018 00019 // OpenNN includes 00020 00021 #include "../utilities/vector.h" 00022 #include "../utilities/matrix.h" 00023 #include "../training_strategy/training_strategy.h" 00024 00025 // TinyXml includes 00026 00027 #include "../../parsers/tinyxml/tinyxml.h" 00028 00029 namespace OpenNN 00030 { 00031 00034 00035 class ModelSelection 00036 { 00037 00038 public: 00039 00040 // DEFAULT CONSTRUCTOR 00041 00042 explicit ModelSelection(void); 00043 00044 // GRADIENT DESCENT CONSTRUCTOR 00045 00046 explicit ModelSelection(TrainingStrategy*); 00047 00048 // FILE CONSTRUCTOR 00049 00050 explicit ModelSelection(const std::string&); 00051 00052 // DESTRUCTOR 00053 00054 virtual ~ModelSelection(void); 00055 00056 // STRUCTURES 00057 00061 00062 struct ModelSelectionResults 00063 { 00065 00066 Matrix< Vector<double> > parameters_data; 00067 00069 00070 Matrix<double> evaluation_data; 00071 00073 00074 Matrix<double> generalization_evaluation_data; 00075 00077 00078 Vector<double> minimal_parameters; 00079 00081 00082 Vector< Vector<double> > evaluation_data_statistics; 00083 00085 00086 Vector< Vector<double> > generalization_evaluation_data_statistics; 00087 }; 00088 00089 // METHODS 00090 00091 // Get methods 00092 00093 TrainingStrategy* get_training_strategy_pointer(void) const; 00094 00095 const Vector<unsigned int>& get_hidden_perceptrons_numbers(void) const; 00096 const unsigned int& get_parameters_assays_number(void) const; 00097 00098 const bool& get_reserve_parameters_data(void); 00099 const bool& get_reserve_evaluation_data(void); 00100 const bool& get_reserve_generalization_evaluation_data(void); 00101 const bool& get_reserve_minimal_parameters(void); 00102 const bool& get_reserve_evaluation_data_statistics(void); 00103 const bool& get_reserve_generalization_evaluation_data_statistics(void); 00104 const bool& get_reserve_model_order_selection_plot(void); 00105 00106 const bool& get_display(void) const; 00107 00108 // Set methods 00109 00110 void set_training_strategy_pointer(TrainingStrategy*); 00111 00112 void set_default(void); 00113 00114 void set_hidden_perceptrons_numbers(const Vector<unsigned int>&); 00115 void set_parameters_assays_number(const unsigned int&); 00116 00117 void set_assays_numbers(const unsigned int&, const unsigned int&); 00118 00119 void set_reserve_parameters_data(const bool&); 00120 void set_reserve_evaluation_data(const bool&); 00121 void set_reserve_generalization_evaluation_data(const bool&); 00122 void set_reserve_minimal_parameters(const bool&); 00123 void set_reserve_evaluation_data_statistics(const bool&); 00124 void set_reserve_generalization_evaluation_data_statistics(const bool&); 00125 void set_reserve_model_order_selection_plot(const bool&); 00126 00127 void set_display(const bool&); 00128 00129 // Model order selection methods 00130 00131 void check(void) const; 00132 00133 ModelSelectionResults perform_model_inputs_selection(void) const; 00134 00135 ModelSelectionResults perform_model_order_selection(void) const; 00136 00137 ModelSelectionResults perform_model_selection(void) const; 00138 00139 // Serialization methods 00140 00141 TiXmlElement* to_XML(void) const; 00142 void from_XML(TiXmlElement*); 00143 00144 void print(void) const; 00145 void save(const std::string&) const; 00146 void load(const std::string&); 00147 00148 // TiXmlElement* get_model_order_selection_data_XML(const ModelSelectionData&) const; 00149 00150 private: 00151 00152 // MEMBERS 00153 00155 00156 TrainingStrategy* training_strategy_pointer; 00157 00159 00160 Vector< Vector<unsigned int> > inputs_indices; 00161 00163 00164 Vector<unsigned int> hidden_perceptrons_numbers; 00165 00167 00168 unsigned int parameters_assays_number; 00169 00170 // Model selection results 00171 00173 00174 bool reserve_parameters_data; 00175 00177 00178 bool reserve_evaluation_data; 00179 00181 00182 bool reserve_generalization_evaluation_data; 00183 00185 00186 bool reserve_minimal_parameters; 00187 00189 00190 bool reserve_evaluation_data_statistics; 00191 00193 00194 bool reserve_generalization_evaluation_data_statistics; 00195 00197 00198 bool reserve_model_order_selection_plot; 00199 00201 00202 bool display; 00203 }; 00204 00205 } 00206 00207 #endif 00208 00209 // OpenNN: Open Neural Networks Library. 00210 // Copyright (C) 2005-2012 Roberto Lopez 00211 // 00212 // This library is free software; you can redistribute it and/or 00213 // modify it under the terms of the GNU Lesser General Public 00214 // License as published by the Free Software Foundation; either 00215 // version 2.1 of the License, or any later version. 00216 // 00217 // This library is distributed in the hope that it will be useful, 00218 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00219 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00220 // Lesser General Public License for more details. 00221 00222 // You should have received a copy of the GNU Lesser General Public 00223 // License along with this library; if not, write to the Free Software 00224 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA