OpenNN  2.2
Open Neural Networks Library
Classes | Public Member Functions | Private Attributes | List of all members
OpenNN::TestingAnalysis Class Reference

#include <testing_analysis.h>

Classes

struct  LinearRegressionResults
 

Public Member Functions

 TestingAnalysis (void)
 
 TestingAnalysis (NeuralNetwork *)
 
 TestingAnalysis (MathematicalModel *)
 
 TestingAnalysis (DataSet *)
 
 TestingAnalysis (NeuralNetwork *, DataSet *)
 
 TestingAnalysis (NeuralNetwork *, MathematicalModel *)
 
 TestingAnalysis (NeuralNetwork *, DataSet *, MathematicalModel *)
 
 TestingAnalysis (const tinyxml2::XMLDocument &)
 
 TestingAnalysis (const std::string &)
 
virtual ~TestingAnalysis (void)
 
NeuralNetworkget_neural_network_pointer (void) const
 
DataSetget_data_set_pointer (void) const
 
MathematicalModelget_mathematical_model_pointer (void) const
 
const bool & get_display (void) const
 
void set_neural_network_pointer (NeuralNetwork *)
 
void set_data_set_pointer (DataSet *)
 
void set_mathematical_model_pointer (MathematicalModel *)
 
void set_display (const bool &)
 
void set_default (void)
 
void check (void) const
 
Vector< Matrix< double > > calculate_target_output_data (void) const
 
Vector< Matrix< double > > calculate_error_data (void) const
 
Vector< Vector< Statistics< double > > > calculate_error_data_statistics (void) const
 
Vector< Matrix< double > > calculate_error_data_statistics_matrices (void) const
 
Vector< Histogram< double > > calculate_error_data_histograms (const size_t &=10) const
 
Vector< Vector< size_t > > calculate_maximal_errors (const size_t &=10) const
 
Vector< LinearRegressionParameters< double > > calculate_linear_regression_parameters (void) const
 
LinearRegressionResults perform_linear_regression_analysis (void) const
 
Vector< double > calculate_binary_classification_tests (void) const
 
Matrix< size_t > calculate_confusion_binary_classification (const Matrix< double > &, const Matrix< double > &) const
 
Matrix< size_t > calculate_confusion_multiple_classification (const Matrix< double > &, const Matrix< double > &) const
 
Matrix< size_t > calculate_confusion (void) const
 
std::string to_string (void) const
 
void print (void) const
 
virtual tinyxml2::XMLDocument * to_XML (void) const
 
virtual void from_XML (const tinyxml2::XMLDocument &)
 
void save (const std::string &) const
 
void load (const std::string &)
 

Private Attributes

NeuralNetworkneural_network_pointer
 
DataSetdata_set_pointer
 
MathematicalModelmathematical_model_pointer
 
bool display
 

Detailed Description

This class contains tools for testing neural networks in different learning tasks. In particular, it can be used for testing function regression, pattern recognition or time series prediction problems.

Definition at line 42 of file testing_analysis.h.

Constructor & Destructor Documentation

OpenNN::TestingAnalysis::TestingAnalysis ( void  )
explicit

Default constructor. It creates a testing analysis object neither associated to a neural network nor to a mathematical model or a data set. By default, it constructs the function regression testing object.

Definition at line 27 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( NeuralNetwork new_neural_network_pointer)
explicit

Neural network constructor. It creates a testing analysis object associated to a neural network but not to a mathematical model or a data set. By default, it constructs the function regression testing object.

Parameters
new_neural_network_pointerPointer to a neural network object.

Definition at line 43 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( MathematicalModel new_mathematical_model_pointer)
explicit

Mathematical mmodel constructor. It creates a testing analysis object not associated to a neural network, not associated to a data set, and associated to a mathematical model. By default, it constructs the inverse problem testing object.

Parameters
new_mathematical_model_pointerPointer to a mathematical model object.

Definition at line 59 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( DataSet new_data_set_pointer)
explicit

Data set constructor. It creates a testing analysis object not associated to a neural network, associated to a data set and not associated to a mathematical model. By default, it constructs the function regression testing object.

Parameters
new_data_set_pointerPointer to a data set object.

Definition at line 75 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( NeuralNetwork new_neural_network_pointer,
DataSet new_data_set_pointer 
)
explicit

Neural network and data set constructor. It creates a testing analysis object associated to a neural network and to a data set. By default, it constructs the function regression testing object.

Parameters
new_neural_network_pointerPointer to a neural network object.
new_data_set_pointerPointer to a data set object.

Definition at line 109 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( NeuralNetwork new_neural_network_pointer,
MathematicalModel new_mathematical_model_pointer 
)
explicit

Neural network and mathematical model constructor. It creates a testing analysis object associated to a neural network and to a mathematical model, but not to a data set. By default, it constructs the inverse problem testing object.

Parameters
new_neural_network_pointerPointer to a neural network object.
new_mathematical_model_pointerPointer to a mathematical model object.

Definition at line 92 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( NeuralNetwork new_neural_network_pointer,
DataSet new_data_set_pointer,
MathematicalModel new_mathematical_model_pointer 
)
explicit

Neural network, mathematical model and data set constructor. It creates a testing analysis object associated to a neural network, a mathematical model and a data set. By default, it constructs the inverse problem testing object.

Parameters
new_neural_network_pointerPointer to a neural network object.
new_mathematical_model_pointerPointer to a mathematical model object.
new_data_set_pointerPointer to a data set object.

Definition at line 127 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( const tinyxml2::XMLDocument &  testing_analysis_document)
explicit

XML constructor. It creates a testing analysis object neither associated to a neural network nor to a mathematical model or a data set. It also loads the members of this object from a TinyXML document.

Parameters
testing_analysis_documentXML document containing the member data.

Definition at line 143 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::TestingAnalysis ( const std::string &  file_name)
explicit

File constructor. It creates a testing analysis object neither associated to a neural network nor to a mathematical model or a data set. It also loads the members of this object from XML file.

Parameters
file_nameName of testing analysis XML file.

Definition at line 161 of file testing_analysis.cpp.

OpenNN::TestingAnalysis::~TestingAnalysis ( void  )
virtual

Destructor. It deletes the function regression testing, pattern recognition testing, time series prediction testing and inverse problem testing objects.

Definition at line 176 of file testing_analysis.cpp.

Member Function Documentation

Vector< double > OpenNN::TestingAnalysis::calculate_binary_classification_tests ( void  ) const

Returns the results of a binary classification test in a single vector. The size of that vector is six. The elements are:

  • Classification accuracy
  • Error rate
  • Sensitivity
  • Specificity
  • Positive likelihood
  • Negative likelihood

Definition at line 923 of file testing_analysis.cpp.

Matrix< size_t > OpenNN::TestingAnalysis::calculate_confusion ( void  ) const

Returns the confusion matrix of a neural network on the testing instances of a data set. If the number of outputs is one, the size of the confusion matrix is two. If the number of outputs is greater than one, the size of the confusion matrix is the number of outputs.

Definition at line 832 of file testing_analysis.cpp.

Matrix< size_t > OpenNN::TestingAnalysis::calculate_confusion_binary_classification ( const Matrix< double > &  actual_data,
const Matrix< double > &  predicted_data 
) const

Returns the confusion matrix for a binary classification problem.

Parameters
actual_dataTesting target data.
predicted_dataTesting output data.

Definition at line 744 of file testing_analysis.cpp.

Matrix< size_t > OpenNN::TestingAnalysis::calculate_confusion_multiple_classification ( const Matrix< double > &  actual_data,
const Matrix< double > &  predicted_data 
) const

Returns the confusion matrix for a binary classification problem.

Parameters
actual_dataTesting target data.
predicted_dataTesting output data.

Definition at line 804 of file testing_analysis.cpp.

Vector< Matrix< double > > OpenNN::TestingAnalysis::calculate_error_data ( void  ) const

Calculates the errors between the outputs from a neural network and the testing instances in a data set. It returns a vector of tree matrices:

  • Absolute error.
  • Relative error.
  • Percentage error.

The number of rows in each matrix is the number of testing instances in the data set. The number of columns is the number of outputs in the neural network.

Definition at line 545 of file testing_analysis.cpp.

Vector< Histogram< double > > OpenNN::TestingAnalysis::calculate_error_data_histograms ( const size_t &  bins_number = 10) const

Calculates histograms for the relative errors of all the output variables. The number of bins is set by the user.

Parameters
bins_numberNumber of bins in the histograms.

Definition at line 698 of file testing_analysis.cpp.

Vector< Vector< Statistics< double > > > OpenNN::TestingAnalysis::calculate_error_data_statistics ( void  ) const

Calculates the basic statistics on the error data.

  • Minimum.
  • Maximum.
  • Mean.
  • Standard deviation

Definition at line 642 of file testing_analysis.cpp.

Vector< Matrix< double > > OpenNN::TestingAnalysis::calculate_error_data_statistics_matrices ( void  ) const

Returns a vector of matrices with the statistics of the errors between the neural network outputs and the testing targets in the data set. The size of the vector is the number of output variables. The number of rows in each submatrix is three (absolute, relative and percentage errors). The number of columns in each submatrix is four (minimum, maximum, mean and standard deviation).

Definition at line 672 of file testing_analysis.cpp.

Vector< LinearRegressionParameters< double > > OpenNN::TestingAnalysis::calculate_linear_regression_parameters ( void  ) const

Performs a linear regression analysis between the testing instances in the data set and the corresponding neural network outputs. It returns all the provided parameters in a vector of vectors. The number of elements in the vector is equal to the number of output variables. The size of each element is equal to the number of regression parameters (2). In this way, each subvector contains the regression parameters intercept and slope of an output variable.

Definition at line 419 of file testing_analysis.cpp.

Vector< Vector< size_t > > OpenNN::TestingAnalysis::calculate_maximal_errors ( const size_t &  instances_number = 10) const

Returns a vector with the indices of the instances which have the greatest error.

Parameters
instances_numberSize of the vector to be returned.
Todo:
Finish the method.

Definition at line 721 of file testing_analysis.cpp.

Vector< Matrix< double > > OpenNN::TestingAnalysis::calculate_target_output_data ( void  ) const

Returns a vector of matrices with number of rows equal to number of testing instances and number of columns equal to two (the targets value and the outputs value).

Definition at line 365 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::check ( void  ) const

Checks that:

  • The neural network pointer is not NULL.
  • The data set pointer is not NULL.

Definition at line 336 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::from_XML ( const tinyxml2::XMLDocument &  document)
virtual

Deserializes a TinyXML document into this testing analysis object.

Parameters
documentXML document containing the member data.

Definition at line 1156 of file testing_analysis.cpp.

const bool & OpenNN::TestingAnalysis::get_display ( void  ) const

Returns true if messages from this class can be displayed on the screen, or false if messages from this class can't be displayed on the screen.

Definition at line 263 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::load ( const std::string &  file_name)

Loads from a XML file the members for this testing analysis object.

Parameters
file_nameName of testing analysis XML file.

Definition at line 1211 of file testing_analysis.cpp.

TestingAnalysis::LinearRegressionResults OpenNN::TestingAnalysis::perform_linear_regression_analysis ( void  ) const

Performs a linear regression analysis of a neural network on the testing indices of a data set. It returns a linear regression analysis results structure, which consists on:

  • Linear regression parameters.
  • Scaled target and output data.

Definition at line 488 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::save ( const std::string &  file_name) const

Saves to a XML file the members of this testing analysis object.

Parameters
file_nameName of testing analysis XML file.

Definition at line 1196 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::set_data_set_pointer ( DataSet new_data_set_pointer)

Sets a new data set to be used for validating the quality of a trained neural network.

Parameters
new_data_set_pointerPointer to a data set object.

Definition at line 309 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::set_default ( void  )

Sets some default values to the testing analysis object:

  • Display: True.

Definition at line 276 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::set_display ( const bool &  new_display)

Sets a new display value. If it is set to true messages from this class are to be displayed on the screen; if it is set to false messages from this class are not to be displayed on the screen.

Parameters
new_displayDisplay value.

Definition at line 322 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::set_mathematical_model_pointer ( MathematicalModel new_mathematical_model_pointer)

Sets a mathematical model to be used for validating the quality of a trained neural network.

Parameters
new_mathematical_model_pointerPointer to a mathematical model object.

Definition at line 298 of file testing_analysis.cpp.

void OpenNN::TestingAnalysis::set_neural_network_pointer ( NeuralNetwork new_neural_network_pointer)

Sets a new neural network object to be tested.

Parameters
new_neural_network_pointerPointer to a neural network object.

Definition at line 287 of file testing_analysis.cpp.

tinyxml2::XMLDocument * OpenNN::TestingAnalysis::to_XML ( void  ) const
virtual

Serializes the testing analysis object into a XML document of the TinyXML library. See the OpenNN manual for more information about the format of this element.

Definition at line 1124 of file testing_analysis.cpp.


The documentation for this class was generated from the following files: