OpenNN  2.2
Open Neural Networks Library
testing_analysis.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.opennn.net */
5 /* */
6 /* T E S T I N G A N A L Y S I S C L A S S H E A D E R */
7 /* */
8 /* Roberto Lopez */
9 /* Artelnics - Making intelligent use of data */
10 /* robertolopez@artelnics.com */
11 /* */
12 /****************************************************************************************************************/
13 
14 #ifndef __TESTINGANALYSIS_H__
15 #define __TESTINGANALYSIS_H__
16 
17 // System includes
18 
19 #include <iostream>
20 #include <fstream>
21 #include <string>
22 #include <sstream>
23 #include <cmath>
24 
25 // OpenNN includes
26 
27 #include "vector.h"
28 #include "matrix.h"
29 
30 #include "data_set.h"
31 #include "mathematical_model.h"
32 
33 #include "neural_network.h"
34 
35 namespace OpenNN
36 {
37 
41 
43 {
44 
45 public:
46 
47  // DEFAULT CONSTRUCTOR
48 
49  explicit TestingAnalysis(void);
50 
51  // NEURAL NETWORK CONSTRUCTOR
52 
53  explicit TestingAnalysis(NeuralNetwork*);
54 
55  // MATHEMATICAL MODEL CONSTRUCTOR
56 
58 
59  // DATA SET CONSTRUCTOR
60 
61  explicit TestingAnalysis(DataSet*);
62 
63  // NEURAL NETWORK AND DATA SET CONSTRUCTOR
64 
66 
67  // NEURAL NETWORK AND MATHEMATICAL MODEL CONSTRUCTOR
68 
70 
71  // NEURAL NETWORK, DATA SET AND MATHEMATICAL MODEL CONSTRUCTOR
72 
74 
75  // XML CONSTRUCTOR
76 
77  explicit TestingAnalysis(const tinyxml2::XMLDocument&);
78 
79  // FILE CONSTRUCTOR
80 
81  explicit TestingAnalysis(const std::string&);
82 
83 
84  // DESTRUCTOR
85 
86  virtual ~TestingAnalysis(void);
87 
88  // STRUCTURES
89 
93 
95  {
97 
99 
101 
103 
104  void save(const std::string&) const;
105  };
106 
110 
112  {
114 
116 
118 
120 
122 
124  };
125 
129 
131  {
133 
135 
137 
139 
141 
143  };
144 
148 
150  {
152 
154 
156 
158 
160 
162 
164 
166  };
167 
168 
169  // METHODS
170 
171  // Get methods
172 
174  DataSet* get_data_set_pointer(void) const;
176 
177  const bool& get_display(void) const;
178 
179  // Set methods
180 
184 
185  void set_display(const bool&);
186 
187  void set_default(void);
188 
189  // Checking methods
190 
191  void check(void) const;
192 
193  // Target and output data methods
194 
196 
197  // Error data methods
198 
200 
203 
205 
206  Vector< Vector<size_t> > calculate_maximal_errors(const size_t& = 10) const;
207 
210 
214 
215  // Linear regression analysis methods
216 
218 
220 
221  // Binary classifcation methods
222 
224 
225  double calculate_logloss(void) const;
226 
227  // Confusion methods
228 
231 
233 
235 
236  // ROC curve
237 
239 
240  double calculate_Wilcoxon_parameter(const double&, const double&) const;
241 
243  double calculate_area_under_curve(const Matrix<double>& ,const Matrix<double>&) const;
244  double calculate_optimal_threshold(const Matrix<double>& ,const Matrix<double>&) const;
245  double calculate_optimal_threshold(const Matrix<double>& ,const Matrix<double>&, const Matrix<double>&) const;
246 
247  // Lift Chart
248 
252 
255 
258 
259  // Calibration plot
260 
262 
264 
265  //Output histogram
266 
267  Vector < Histogram <double> > calculate_output_histogram(const Matrix<double>& , const size_t& = 10) const;
268 
269  // Binary classification rates
270 
272 
277 
278  // Multiple classification rates
279 
281 
283 
284  // Forecasting methods
285 
286  Vector< Vector<double> > calculate_error_autocorrelation(const size_t& = 10) const;
288 
289  // Serialization methods
290 
291  std::string to_string(void) const;
292 
293  void print(void) const;
294 
295  virtual tinyxml2::XMLDocument* to_XML(void) const;
296  virtual void from_XML(const tinyxml2::XMLDocument&);
297 
298  virtual void write_XML(tinyxml2::XMLPrinter&) const;
299  //virtual void read_XML( );
300 
301  void save(const std::string&) const;
302  void load(const std::string&);
303 
304 
305 private:
306 
307  // MEMBERS
308 
310 
312 
314 
316 
318 
320 
322 
323  bool display;
324 };
325 
326 }
327 
328 #endif
329 
330 // OpenNN: Open Neural Networks Library.
331 // Copyright (c) 2005-2016 Roberto Lopez.
332 //
333 // This library is free software; you can redistribute it and/or
334 // modify it under the terms of the GNU Lesser General Public
335 // License as published by the Free Software Foundation; either
336 // version 2.1 of the License, or any later version.
337 //
338 // This library is distributed in the hope that it will be useful,
339 // but WITHOUT ANY WARRANTY; without even the implied warranty of
340 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
341 // Lesser General Public License for more details.
342 
343 // You should have received a copy of the GNU Lesser General Public
344 // License along with this library; if not, write to the Free Software
345 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
double calculate_testing_normalized_squared_error(const Matrix< double > &, const Matrix< double > &) const
MathematicalModel * get_mathematical_model_pointer(void) const
Returns a pointer to the mathematical model object on which the neural network is tested...
double calculate_testing_cross_entropy_error(const Matrix< double > &, const Matrix< double > &) const
double calculate_area_under_curve(const Matrix< double > &, const Matrix< double > &) const
Vector< Histogram< double > > calculate_error_data_histograms(const size_t &=10) const
bool display
Display messages to screen.
std::string to_string(void) const
Returns a string representation of the testing analysis object.
Vector< double > calculate_testing_errors(void) const
Matrix< double > calculate_calibration_plot(const Matrix< double > &, const Matrix< double > &) const
Matrix< size_t > calculate_confusion_multiple_classification(const Matrix< double > &, const Matrix< double > &) const
Vector< size_t > calculate_true_positive_instances(const Matrix< double > &, const Matrix< double > &, const Vector< size_t > &, const double &) const
NeuralNetwork * get_neural_network_pointer(void) const
Returns a pointer to the neural network object which is to be tested.
void set_mathematical_model_pointer(MathematicalModel *)
void set_display(const bool &)
double calculate_Wilcoxon_parameter(const double &, const double &) const
Vector< size_t > calculate_true_negative_instances(const Matrix< double > &, const Matrix< double > &, const Vector< size_t > &, const double &) const
Vector< LinearRegressionParameters< double > > linear_regression_parameters
Intercept, slope and correlation coefficient for each output variable.
Vector< Vector< size_t > > calculate_maximal_errors(const size_t &=10) const
Vector< LinearRegressionParameters< double > > calculate_linear_regression_parameters(void) const
Vector< size_t > calculate_false_negative_instances(const Matrix< double > &, const Matrix< double > &, const Vector< size_t > &, const double &) const
Vector< double > calculate_binary_classification_tests(void) const
double area_under_curve
Area under a ROC curve.
virtual void write_XML(tinyxml2::XMLPrinter &) const
LinearRegressionResults perform_linear_regression_analysis(void) const
void set_data_set_pointer(DataSet *)
DataSet * get_data_set_pointer(void) const
Returns a pointer to the data set object on which the neural network is tested.
Matrix< size_t > calculate_confusion_binary_classification(const Matrix< double > &, const Matrix< double > &, const double &) const
Vector< Vector< double > > calculate_error_autocorrelation(const size_t &=10) const
Matrix< double > calculate_lift_chart(const Matrix< double > &) const
BinaryClassifcationRates calculate_binary_classification_rates(void) const
Vector< size_t > false_positive_instances
Vector with the indices of the instances which are false positive.
Matrix< double > negative_cumulative_gain
Matrix containing the data of a negative cumulative gain.
double calculate_logloss(void) const
Returns the logloss for a binary classification problem.
Vector< double > calculate_maximum_gain(const Matrix< double > &, const Matrix< double > &) const
Vector< double > calculate_classification_testing_errors(void) const
Vector< Matrix< double > > calculate_error_data_statistics_matrices(void) const
Matrix< double > positive_cumulative_gain
Matrix containing the data of a positive cumulative gain.
double optimal_threshold
Optimal threshold of a ROC curve.
KolmogorovSmirnovResults perform_Kolmogorov_Smirnov_analysis(void) const
NeuralNetwork * neural_network_pointer
Pointer to the neural network object to be tested.
void set_neural_network_pointer(NeuralNetwork *)
Vector< Matrix< double > > calculate_target_output_data(void) const
Vector< size_t > calculate_false_positive_instances(const Matrix< double > &, const Matrix< double > &, const Vector< size_t > &, const double &) const
Vector< size_t > true_negative_instances
Vector with the indices of the instances which are true negative.
void print(void) const
Prints to the standard output the string representation of this testing analysis object.
double calculate_optimal_threshold(const Matrix< double > &, const Matrix< double > &) const
Matrix< Vector< size_t > > calculate_multiple_classification_rates(void) const
Returns a matrix of subvectors which have the rates for a multiple classification problem...
void load(const std::string &)
Vector< Histogram< double > > calculate_output_histogram(const Matrix< double > &, const size_t &=10) const
Vector< Matrix< double > > target_output_data
Target data from data set and output data from neural network.
const bool & get_display(void) const
Matrix< double > perform_calibration_plot_analysis(void) const
Performs a calibration plot analysis.
Matrix< double > perform_lift_chart_analysis(void) const
Matrix< double > calculate_cumulative_gain(const Matrix< double > &, const Matrix< double > &) const
Matrix< double > perform_cumulative_gain_analysis(void) const
Matrix< size_t > calculate_confusion(void) const
DataSet * data_set_pointer
Pointer to a data set object.
Vector< double > maximum_gain
Maximum gain of the cumulative gain analysis.
virtual void from_XML(const tinyxml2::XMLDocument &)
virtual tinyxml2::XMLDocument * to_XML(void) const
double calculate_testing_weighted_squared_error(const Matrix< double > &, const Matrix< double > &) const
RocAnalysisResults perform_roc_analysis(void) const
Vector< Vector< Statistics< double > > > calculate_error_data_statistics(void) const
Vector< Vector< double > > calculate_input_error_cross_correlation(const size_t &=10) const
Matrix< double > calculate_negative_cumulative_gain(const Matrix< double > &, const Matrix< double > &) const
MathematicalModel * mathematical_model_pointer
Pointer to a mathematical model object.
Vector< size_t > true_positive_instances
Vector with the indices of the instances which are true positive.
Matrix< double > roc_curve
Matrix containing the data of a ROC curve.
Matrix< double > calculate_roc_curve(const Matrix< double > &, const Matrix< double > &) const
Vector< Matrix< double > > calculate_error_data(void) const
Vector< size_t > false_negative_instances
Vector with the indices of the instances which are false negative.
Vector< size_t > calculate_positives_negatives_rate(const Matrix< double > &, const Matrix< double > &) const