TestingAnalysis Class Reference

This class contains tools for testing neural networks in different learning tasks. More...

#include <testing_analysis.h>

Classes

struct  BinaryClassifcationRates
 Structure with the binary classification rates. More...
 
struct  KolmogorovSmirnovResults
 Structure with the results from Kolmogorov-Smirnov analysis. More...
 
struct  LinearRegressionAnalysis
 Structure with the results from a linear regression analysis. More...
 
struct  RocAnalysisResults
 Structure with the results from a roc curve analysis. More...
 

Public Member Functions

 TestingAnalysis ()
 
 TestingAnalysis (NeuralNetwork *, DataSet *)
 
virtual ~TestingAnalysis ()
 
NeuralNetworkget_neural_network_pointer () const
 Returns a pointer to the neural network object which is to be tested. More...
 
DataSetget_data_set_pointer () const
 Returns a pointer to the data set object on which the neural network is tested. More...
 
const bool & get_display () const
 
void set_neural_network_pointer (NeuralNetwork *)
 
void set_data_set_pointer (DataSet *)
 
void set_display (const bool &)
 
void set_default ()
 
void set_threads_number (const int &)
 
void check () const
 
Tensor< type, 3 > calculate_error_data () const
 
Tensor< type, 2 > calculate_percentage_error_data () const
 
Tensor< Descriptives, 1 > calculate_absolute_errors_descriptives () const
 
Tensor< Descriptives, 1 > calculate_absolute_errors_descriptives (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< Descriptives, 1 > calculate_percentage_errors_descriptives () const
 
Tensor< Descriptives, 1 > calculate_percentage_errors_descriptives (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< Tensor< Descriptives, 1 >, 1 > calculate_error_data_descriptives () const
 
void print_error_data_descriptives () const
 
Tensor< Histogram, 1 > calculate_error_data_histograms (const Index &=10) const
 
Tensor< Tensor< Index, 1 >, 1 > calculate_maximal_errors (const Index &=10) const
 
Tensor< type, 2 > calculate_errors () const
 
Tensor< type, 2 > calculate_binary_classification_errors () const
 
Tensor< type, 2 > calculate_multiple_classification_errors () const
 
Tensor< type, 1 > calculate_training_errors () const
 
Tensor< type, 1 > calculate_binary_classification_training_errors () const
 
Tensor< type, 1 > calculate_multiple_classification_training_errors () const
 
Tensor< type, 1 > calculate_selection_errors () const
 
Tensor< type, 1 > calculate_binary_classification_selection_errors () const
 
Tensor< type, 1 > calculate_multiple_classification_selection_errors () const
 
Tensor< type, 1 > calculate_testing_errors () const
 
Tensor< type, 1 > calculate_binary_classification_testing_errors () const
 
Tensor< type, 1 > calculate_multiple_classification_testing_errors () const
 
type calculate_normalized_squared_error (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
type calculate_cross_entropy_error (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
type calculate_weighted_squared_error (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< type, 1 > &=Tensor< type, 1 >()) const
 
type calculate_Minkowski_error (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const type=type(1.5)) const
 
Tensor< Correlation, 1 > linear_correlation () const
 
Tensor< Correlation, 1 > linear_correlation (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
void print_linear_regression_correlations () const
 
Tensor< LinearRegressionAnalysis, 1 > perform_linear_regression_analysis () const
 
void print_linear_regression_analysis () const
 
Tensor< type, 1 > calculate_binary_classification_tests () const
 
void print_binary_classification_tests () const
 
type calculate_logloss () const
 Returns the logloss for a binary classification problem. More...
 
Tensor< Index, 2 > calculate_confusion_binary_classification (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const type &) const
 
Tensor< Index, 2 > calculate_confusion_multiple_classification (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< Index, 1 > calculate_positives_negatives_rate (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< Index, 2 > calculate_confusion (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< Index, 2 > calculate_confusion () const
 
RocAnalysisResults perform_roc_analysis () const
 
type calculate_Wilcoxon_parameter (const type &, const type &) const
 
Tensor< type, 2 > calculate_roc_curve (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
type calculate_area_under_curve (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
type calculate_area_under_curve (const Tensor< type, 2 > &) const
 
type calculate_area_under_curve_confidence_limit (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
type calculate_area_under_curve_confidence_limit (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const type &) const
 
type calculate_optimal_threshold (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
type calculate_optimal_threshold (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< type, 2 > perform_cumulative_gain_analysis () const
 
Tensor< type, 2 > calculate_cumulative_gain (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< type, 2 > calculate_negative_cumulative_gain (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< type, 2 > perform_lift_chart_analysis () const
 
Tensor< type, 2 > calculate_lift_chart (const Tensor< type, 2 > &) const
 
KolmogorovSmirnovResults perform_Kolmogorov_Smirnov_analysis () const
 
Tensor< type, 1 > calculate_maximum_gain (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< type, 2 > perform_calibration_plot_analysis () const
 Performs a calibration plot analysis. More...
 
Tensor< type, 2 > calculate_calibration_plot (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
Tensor< Histogram, 1 > calculate_output_histogram (const Tensor< type, 2 > &, const Index &=10) const
 
BinaryClassifcationRates calculate_binary_classification_rates () const
 
Tensor< Index, 1 > calculate_true_positive_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< Index, 1 > &, const type &) const
 
Tensor< Index, 1 > calculate_false_positive_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< Index, 1 > &, const type &) const
 
Tensor< Index, 1 > calculate_false_negative_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< Index, 1 > &, const type &) const
 
Tensor< Index, 1 > calculate_true_negative_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< Index, 1 > &, const type &) const
 
Tensor< type, 1 > calculate_multiple_classification_tests () const
 
void save_confusion (const string &) const
 
void save_multiple_classification_tests (const string &) const
 
Tensor< Tensor< Index, 1 >, 2 > calculate_multiple_classification_rates () const
 Returns a matrix of subvectors which have the rates for a multiple classification problem. More...
 
Tensor< Tensor< Index, 1 >, 2 > calculate_multiple_classification_rates (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< Index, 1 > &) const
 
Tensor< string, 2 > calculate_well_classified_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &)
 
Tensor< string, 2 > calculate_misclassified_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &)
 
void save_well_classified_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &, const string &)
 
void save_misclassified_samples (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &, const string &)
 
void save_well_classified_samples_statistics (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &, const string &)
 
void save_misclassified_samples_statistics (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &, const string &)
 
void save_well_classified_samples_probability_histogram (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &, const string &)
 
void save_well_classified_samples_probability_histogram (const Tensor< string, 2 > &, const string &)
 
void save_misclassified_samples_probability_histogram (const Tensor< type, 2 > &, const Tensor< type, 2 > &, const Tensor< string, 1 > &, const string &)
 
void save_misclassified_samples_probability_histogram (const Tensor< string, 2 > &, const string &)
 
Tensor< Tensor< type, 1 >, 1 > calculate_error_autocorrelation (const Index &=10) const
 
Tensor< Tensor< type, 1 >, 1 > calculate_inputs_errors_cross_correlation (const Index &=10) const
 
void print () const
 Prints to the standard output the string representation of this testing analysis object. More...
 
virtual void from_XML (const tinyxml2::XMLDocument &)
 
virtual void write_XML (tinyxml2::XMLPrinter &) const
 
void save (const string &) const
 
void load (const string &)
 
bool contains (const Tensor< type, 1 > &, const type &) const
 
Tensor< type, 2 > delete_row (const Tensor< type, 2 > &, const Index &) const
 

Private Attributes

NonBlockingThreadPool * non_blocking_thread_pool = nullptr
 
ThreadPoolDevice * thread_pool_device = nullptr
 
NeuralNetworkneural_network_pointer = nullptr
 Pointer to the neural network object to be tested. More...
 
DataSetdata_set_pointer = nullptr
 Pointer to a data set object. More...
 
bool display = true
 Display messages to screen. More...
 
const Eigen::array< IndexPair< Index >, 2 > SSE = {IndexPair<Index>(0, 0), IndexPair<Index>(1, 1)}
 

Detailed Description

This class contains tools for testing neural networks in different learning tasks.

In particular, it can be used for testing function regression, classification or time series prediction problems.

Definition at line 41 of file testing_analysis.h.

Constructor & Destructor Documentation

◆ TestingAnalysis() [1/2]

TestingAnalysis ( )
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 18 of file testing_analysis.cpp.

◆ TestingAnalysis() [2/2]

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 32 of file testing_analysis.cpp.

◆ ~TestingAnalysis()

~TestingAnalysis ( )
virtual

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

Definition at line 45 of file testing_analysis.cpp.

Member Function Documentation

◆ calculate_absolute_errors_descriptives() [1/2]

Tensor< Descriptives, 1 > calculate_absolute_errors_descriptives ( ) const

Definition at line 497 of file testing_analysis.cpp.

◆ calculate_absolute_errors_descriptives() [2/2]

Tensor< Descriptives, 1 > calculate_absolute_errors_descriptives ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Definition at line 514 of file testing_analysis.cpp.

◆ calculate_area_under_curve() [1/2]

type calculate_area_under_curve ( const Tensor< type, 2 > &  roc_curve) const

Returns the area under a ROC curve using trapezoidal integration.

Parameters
roc_curveROC curve.

Definition at line 1928 of file testing_analysis.cpp.

◆ calculate_area_under_curve() [2/2]

type calculate_area_under_curve ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns the area under a ROC curve using Wilcoxon parameter test.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 1868 of file testing_analysis.cpp.

◆ calculate_area_under_curve_confidence_limit() [1/2]

type calculate_area_under_curve_confidence_limit ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns the confidence limit for the area under a roc curve.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 1945 of file testing_analysis.cpp.

◆ calculate_area_under_curve_confidence_limit() [2/2]

type calculate_area_under_curve_confidence_limit ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const type &  area_under_curve 
) const

Returns the confidence limit for the area under a roc curve.

Parameters
targetsTesting target data.
outputsTesting output data.
area_under_curveArea under curve.

Definition at line 1992 of file testing_analysis.cpp.

◆ calculate_binary_classification_errors()

Tensor< type, 2 > calculate_binary_classification_errors ( ) const

Definition at line 694 of file testing_analysis.cpp.

◆ calculate_binary_classification_rates()

TestingAnalysis::BinaryClassifcationRates calculate_binary_classification_rates ( ) const

Returns a structure with the binary classification rates, which has the indices of the true positive, false negative, false positive and true negative samples.

  • True positive samples
  • False positive samples
  • False negative samples
  • True negative samples

Definition at line 2736 of file testing_analysis.cpp.

◆ calculate_binary_classification_selection_errors()

Tensor< type, 1 > calculate_binary_classification_selection_errors ( ) const

Definition at line 974 of file testing_analysis.cpp.

◆ calculate_binary_classification_testing_errors()

Tensor< type, 1 > calculate_binary_classification_testing_errors ( ) const

Returns a vector containing the values of the errors between the outputs of the neural network and the targets for a binary classification problem. The vector consists of:

  • Sum squared error.
  • Mean squared error.
  • Root mean squared error.
  • Normalized squared error.
  • Cross-entropy error.
  • Weighted squared error.

Definition at line 1147 of file testing_analysis.cpp.

◆ calculate_binary_classification_tests()

Tensor< type, 1 > calculate_binary_classification_tests ( ) const

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

  • Classification accuracy
  • Error rate
  • Sensitivity
  • Specificity
  • Precision
  • Positive likelihood
  • Negative likelihood
  • F1 score
  • False positive rate
  • False discovery rate
  • False negative rate
  • Negative predictive value
  • Matthews correlation coefficient
  • Informedness
  • Markedness

Definition at line 3577 of file testing_analysis.cpp.

◆ calculate_binary_classification_training_errors()

Tensor< type, 1 > calculate_binary_classification_training_errors ( ) const

Definition at line 813 of file testing_analysis.cpp.

◆ calculate_calibration_plot()

Tensor< type, 2 > calculate_calibration_plot ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns a matix with the values of a calibration plot. Number of columns is two. Number of rows varies depending on the distribution of positive targets.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 2629 of file testing_analysis.cpp.

◆ calculate_confusion()

Tensor< Index, 2 > calculate_confusion ( ) const

Returns the confusion matrix of a neural network on the testing samples 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 1553 of file testing_analysis.cpp.

◆ calculate_confusion_binary_classification()

Tensor< Index, 2 > calculate_confusion_binary_classification ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const type &  decision_threshold 
) const

Returns the confusion matrix for a binary classification problem.

Parameters
targetsTesting target data.
outputsTesting output data.
decision_thresholdDecision threshold.

Definition at line 1420 of file testing_analysis.cpp.

◆ calculate_confusion_multiple_classification()

Tensor< Index, 2 > calculate_confusion_multiple_classification ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns the confusion matrix for a binary classification problem.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 1495 of file testing_analysis.cpp.

◆ calculate_cross_entropy_error()

type calculate_cross_entropy_error ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns the cross-entropy error between the targets and the outputs of the neural network. It can only be computed for classification problems.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 1291 of file testing_analysis.cpp.

◆ calculate_cumulative_gain()

Tensor< type, 2 > calculate_cumulative_gain ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns a matrix with the values of a cumulative gain chart. The number of columns is two, the number of rows is 20.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 2208 of file testing_analysis.cpp.

◆ calculate_error_autocorrelation()

Tensor< Tensor< type, 1 >, 1 > calculate_error_autocorrelation ( const Index &  maximum_lags_number = 10) const

Calculates error autocorrelation across varying lags. Returns a vector of subvectors. The size of the vector is the number of targets. The size of the subvectors is the number of lags for which autocorrelation is calculated.

Parameters
maximum_lags_numberNumber of lags for which error autocorrelation is to be calculated.

Definition at line 3414 of file testing_analysis.cpp.

◆ calculate_error_data()

Tensor< type, 3 > calculate_error_data ( ) const

Calculates the errors between the outputs from a neural network and the testing samples 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 samples in the data set. The number of columns is the number of outputs in the neural network.

Definition at line 340 of file testing_analysis.cpp.

◆ calculate_error_data_descriptives()

Tensor< Tensor< Descriptives, 1 >, 1 > calculate_error_data_descriptives ( ) const

Calculates the basic descriptives on the error data.

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

Definition at line 557 of file testing_analysis.cpp.

◆ calculate_error_data_histograms()

Tensor< Histogram, 1 > calculate_error_data_histograms ( const Index &  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 617 of file testing_analysis.cpp.

◆ calculate_errors()

Tensor< type, 2 > calculate_errors ( ) const

This method calculates the training, selection and testing errors. Returns a matrix with the differents errors.

Definition at line 664 of file testing_analysis.cpp.

◆ calculate_false_negative_samples()

Tensor< Index, 1 > calculate_false_negative_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< Index, 1 > &  testing_indices,
const type &  decision_threshold 
) const

Returns a vector with the indices of the false negative samples. The size of the vector is the number of false negative samples.

Parameters
targetsTesting target data.
outputsTesting output data.
testing_indicesIndices of the testing data
decision_thresholdDecision threshold.

Definition at line 2886 of file testing_analysis.cpp.

◆ calculate_false_positive_samples()

Tensor< Index, 1 > calculate_false_positive_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< Index, 1 > &  testing_indices,
const type &  decision_threshold 
) const

Returns a vector with the indices of the false positive samples. The size of the vector is the number of false positive samples.

Parameters
targetsTesting target data.
outputsTesting output data.
testing_indicesIndices of the testing data
decision_thresholdDecision threshold.

Definition at line 2853 of file testing_analysis.cpp.

◆ calculate_inputs_errors_cross_correlation()

Tensor< Tensor< type, 1 >, 1 > calculate_inputs_errors_cross_correlation ( const Index &  lags_number = 10) const

Calculates the correlation between input and error. Returns a vector of subvectors. The size of the vector is the number of targets. The size of the subvectors is the number of lags for which cross-correlation is calculated.

Parameters
maximum_lags_numberNumber of lags for which cross-correlation is calculated.

Definition at line 3487 of file testing_analysis.cpp.

◆ calculate_lift_chart()

Tensor< type, 2 > calculate_lift_chart ( const Tensor< type, 2 > &  cumulative_gain) const

Returns a matrix with the values of lift chart for a given cumulative gain chart. Size is the same as the cumulative lift chart one.

Parameters
cumulative_gainA cumulative gain chart.

Definition at line 2420 of file testing_analysis.cpp.

◆ calculate_logloss()

type calculate_logloss ( ) const

Returns the logloss for a binary classification problem.

Definition at line 3875 of file testing_analysis.cpp.

◆ calculate_maximal_errors()

Tensor< Tensor< Index, 1 >, 1 > calculate_maximal_errors ( const Index &  samples_number = 10) const

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

Parameters
samples_numberNumber of maximal indices to be computed.

Definition at line 637 of file testing_analysis.cpp.

◆ calculate_maximum_gain()

Tensor< type, 1 > calculate_maximum_gain ( const Tensor< type, 2 > &  positive_cumulative_gain,
const Tensor< type, 2 > &  negative_cumulative_gain 
) const

Returns the score of the the maximum gain, which is the point of major separation between the positive and the negative cumulative gain charts, and the samples ratio for which it occurs.

Parameters
positive_cumulative_gainCumulative gain fo the positive samples.
negative_cumulative_gainCumulative gain fo the negative samples.

Definition at line 2522 of file testing_analysis.cpp.

◆ calculate_Minkowski_error()

type calculate_Minkowski_error ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const type  minkowski_parameter = type(1.5) 
) const

Definition at line 1407 of file testing_analysis.cpp.

◆ calculate_misclassified_samples()

Tensor< string, 2 > calculate_misclassified_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels 
)

Definition at line 3182 of file testing_analysis.cpp.

◆ calculate_multiple_classification_errors()

Tensor< type, 2 > calculate_multiple_classification_errors ( ) const

Definition at line 730 of file testing_analysis.cpp.

◆ calculate_multiple_classification_rates() [1/2]

Tensor< Tensor< Index, 1 >, 2 > calculate_multiple_classification_rates ( ) const

Returns a matrix of subvectors which have the rates for a multiple classification problem.

Definition at line 3034 of file testing_analysis.cpp.

◆ calculate_multiple_classification_rates() [2/2]

Tensor< Tensor< Index, 1 >, 2 > calculate_multiple_classification_rates ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< Index, 1 > &  testing_indices 
) const

Returns a matrix of subvectors which have the rates for a multiple classification problem. The number of rows of the matrix is the number targets. The number of columns of the matrix is the number of columns of the target data.

Definition at line 3096 of file testing_analysis.cpp.

◆ calculate_multiple_classification_selection_errors()

Tensor< type, 1 > calculate_multiple_classification_selection_errors ( ) const

Definition at line 1026 of file testing_analysis.cpp.

◆ calculate_multiple_classification_testing_errors()

Tensor< type, 1 > calculate_multiple_classification_testing_errors ( ) const

Returns a vector containing the values of the errors between the outputs of the neural network and the targets for a multiple classification problem. The vector consists of:

  • Sum squared error.
  • Mean squared error.
  • Root mean squared error.
  • Normalized squared error.
  • Cross-entropy error.

Definition at line 1209 of file testing_analysis.cpp.

◆ calculate_multiple_classification_tests()

Tensor< type, 1 > calculate_multiple_classification_tests ( ) const

Definition at line 2945 of file testing_analysis.cpp.

◆ calculate_multiple_classification_training_errors()

Tensor< type, 1 > calculate_multiple_classification_training_errors ( ) const

Definition at line 874 of file testing_analysis.cpp.

◆ calculate_negative_cumulative_gain()

Tensor< type, 2 > calculate_negative_cumulative_gain ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns a matrix with the values of a cumulative gain chart for the negative samples. The number of columns is two, the number of rows is 20.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 2284 of file testing_analysis.cpp.

◆ calculate_normalized_squared_error()

type calculate_normalized_squared_error ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns the normalized squared error between the targets and the outputs of the neural network.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 1263 of file testing_analysis.cpp.

◆ calculate_optimal_threshold() [1/2]

type calculate_optimal_threshold ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns the point of optimal classification accuracy, which is the nearest ROC curve point to the upper left corner(0,1).

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 2036 of file testing_analysis.cpp.

◆ calculate_optimal_threshold() [2/2]

type calculate_optimal_threshold ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< type, 2 > &  roc_curve 
) const

Returns the point of optimal classification accuracy, which is the nearest ROC curve point to the upper left corner(0,1).

Parameters
targetsTesting target data.
outputsTesting output data.
roc_curveROC curve.

Definition at line 2109 of file testing_analysis.cpp.

◆ calculate_output_histogram()

Tensor< Histogram, 1 > calculate_output_histogram ( const Tensor< type, 2 > &  outputs,
const Index &  bins_number = 10 
) const

Returns the histogram of the outputs.

Parameters
outputsTesting output data.
bins_numberNumber of bins of the histogram.

Definition at line 2716 of file testing_analysis.cpp.

◆ calculate_percentage_error_data()

Tensor< type, 2 > calculate_percentage_error_data ( ) const

Calculates the percentege errors between the outputs from a neural network and the testing samples in a data set. The number of rows in each matrix is the number of testing samples in the data set.

Definition at line 424 of file testing_analysis.cpp.

◆ calculate_percentage_errors_descriptives() [1/2]

Tensor< Descriptives, 1 > calculate_percentage_errors_descriptives ( ) const

Definition at line 523 of file testing_analysis.cpp.

◆ calculate_percentage_errors_descriptives() [2/2]

Tensor< Descriptives, 1 > calculate_percentage_errors_descriptives ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Definition at line 540 of file testing_analysis.cpp.

◆ calculate_positives_negatives_rate()

Tensor< Index, 1 > calculate_positives_negatives_rate ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns a vector containing the number of total positives and the number of total negatives samples of a data set. The size of the vector is two and consists of:

  • Total positives.
  • Total negatives.

Definition at line 1537 of file testing_analysis.cpp.

◆ calculate_roc_curve()

Tensor< type, 2 > calculate_roc_curve ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs 
) const

Returns a matrix with the values of a ROC curve for a binary classification problem. The number of columns is three. The third column contains the decision threshold. The number of rows is one more than the number of outputs if the number of outputs is lower than 100 or 50 in other case.

Parameters
targetsTesting target data.
outputsTesting output data.

Definition at line 1740 of file testing_analysis.cpp.

◆ calculate_selection_errors()

Tensor< type, 1 > calculate_selection_errors ( ) const

Definition at line 924 of file testing_analysis.cpp.

◆ calculate_testing_errors()

Tensor< type, 1 > calculate_testing_errors ( ) const

Returns a vector containing the values of the errors between the outputs of the neural network and the targets. The vector consists of:

  • Sum squared error.
  • Mean squared error.
  • Root mean squared error.
  • Normalized squared error.

Definition at line 1086 of file testing_analysis.cpp.

◆ calculate_training_errors()

Tensor< type, 1 > calculate_training_errors ( ) const

Definition at line 763 of file testing_analysis.cpp.

◆ calculate_true_negative_samples()

Tensor< Index, 1 > calculate_true_negative_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< Index, 1 > &  testing_indices,
const type &  decision_threshold 
) const

Returns a vector with the indices of the true negative samples. The size of the vector is the number of true negative samples.

Parameters
targetsTesting target data.
outputsTestinga output data.
testing_indicesIndices of the testing data
decision_thresholdDecision threshold.

Definition at line 2919 of file testing_analysis.cpp.

◆ calculate_true_positive_samples()

Tensor< Index, 1 > calculate_true_positive_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< Index, 1 > &  testing_indices,
const type &  decision_threshold 
) const

Returns a vector with the indices of the true positive samples. The size of the vector is the number of true positive samples.

Parameters
targetsTesting target data.
outputsTesting outputs.
testing_indicesIndices of testing data.
decision_thresholdDecision threshold.

Definition at line 2819 of file testing_analysis.cpp.

◆ calculate_weighted_squared_error()

type calculate_weighted_squared_error ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< type, 1 > &  weights = Tensor<type, 1>() 
) const

Returns the weighted squared error between the targets and the outputs of the neural network. It can only be computed for binary classification problems.

Parameters
targetsTesting target data.
outputsTesting output data.
weightsWeights of the postitives and negatives to evaluate.

Definition at line 1335 of file testing_analysis.cpp.

◆ calculate_well_classified_samples()

Tensor< string, 2 > calculate_well_classified_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels 
)

Definition at line 3139 of file testing_analysis.cpp.

◆ calculate_Wilcoxon_parameter()

type calculate_Wilcoxon_parameter ( const type &  x,
const type &  y 
) const

Calculates the Wilcoxon parameter, which is used for calculating the area under a ROC curve. Returns 1 if first value is greater than second one, 0 if second value is greater than first one or 0.5 in other case.

Parameters
xTarget data value.
yTarget data value.

Definition at line 1716 of file testing_analysis.cpp.

◆ check()

void check ( ) const

Checks that:

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

Definition at line 168 of file testing_analysis.cpp.

◆ contains()

bool contains ( const Tensor< type, 1 > &  tensor,
const type &  value 
) const

Definition at line 4049 of file testing_analysis.cpp.

◆ delete_row()

Tensor< type, 2 > delete_row ( const Tensor< type, 2 > &  tensor,
const Index &  row_index 
) const

Definition at line 4058 of file testing_analysis.cpp.

◆ from_XML()

void 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 3974 of file testing_analysis.cpp.

◆ get_data_set_pointer()

DataSet * get_data_set_pointer ( ) const

Returns a pointer to the data set object on which the neural network is tested.

Definition at line 77 of file testing_analysis.cpp.

◆ get_display()

const bool & get_display ( ) 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 101 of file testing_analysis.cpp.

◆ get_neural_network_pointer()

NeuralNetwork * get_neural_network_pointer ( ) const

Returns a pointer to the neural network object which is to be tested.

Definition at line 54 of file testing_analysis.cpp.

◆ linear_correlation() [1/2]

Tensor< Correlation, 1 > linear_correlation ( ) const

Performs a linear regression analysis between the testing samples 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 199 of file testing_analysis.cpp.

◆ linear_correlation() [2/2]

Tensor< Correlation, 1 > linear_correlation ( const Tensor< type, 2 > &  target,
const Tensor< type, 2 > &  output 
) const

Definition at line 232 of file testing_analysis.cpp.

◆ load()

void load ( const 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 4029 of file testing_analysis.cpp.

◆ perform_calibration_plot_analysis()

Tensor< type, 2 > perform_calibration_plot_analysis ( ) const

Performs a calibration plot analysis.

Definition at line 2565 of file testing_analysis.cpp.

◆ perform_cumulative_gain_analysis()

Tensor< type, 2 > perform_cumulative_gain_analysis ( ) const

Performs a cumulative gain analysis. Returns a matrix with the values of a cumulative gain chart.

Definition at line 2137 of file testing_analysis.cpp.

◆ perform_Kolmogorov_Smirnov_analysis()

TestingAnalysis::KolmogorovSmirnovResults perform_Kolmogorov_Smirnov_analysis ( ) const

Performs a Kolmogorov-Smirnov analysis, which consists of the cumulative gain for the positive samples and the cumulative gain for the negative samples. It returns a Kolmogorov-Smirnov results structure, which consists of:

  • Positive cumulative gain
  • Negative cumulative gain
  • Maximum gain

Definition at line 2450 of file testing_analysis.cpp.

◆ perform_lift_chart_analysis()

Tensor< type, 2 > perform_lift_chart_analysis ( ) const

Performs a lift chart analysis. Returns a matrix with the values of a lift chart.

Definition at line 2357 of file testing_analysis.cpp.

◆ perform_linear_regression_analysis()

Tensor< TestingAnalysis::LinearRegressionAnalysis, 1 > perform_linear_regression_analysis ( ) 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 of:

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

Definition at line 269 of file testing_analysis.cpp.

◆ perform_roc_analysis()

TestingAnalysis::RocAnalysisResults perform_roc_analysis ( ) const

Performs a ROC curve analysis. It returns a ROC curve analysis results structure, which consists of:

  • ROC curve
  • Area under the ROC curve
  • Optimal threshold

Definition at line 1636 of file testing_analysis.cpp.

◆ print()

void print ( ) const

Prints to the standard output the string representation of this testing analysis object.

Definition at line 3942 of file testing_analysis.cpp.

◆ print_binary_classification_tests()

void print_binary_classification_tests ( ) const

Definition at line 3861 of file testing_analysis.cpp.

◆ print_error_data_descriptives()

void print_error_data_descriptives ( ) const

Definition at line 588 of file testing_analysis.cpp.

◆ print_linear_regression_analysis()

void print_linear_regression_analysis ( ) const

Definition at line 319 of file testing_analysis.cpp.

◆ print_linear_regression_correlations()

void print_linear_regression_correlations ( ) const

Definition at line 247 of file testing_analysis.cpp.

◆ save()

void save ( const 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 4012 of file testing_analysis.cpp.

◆ save_confusion()

void save_confusion ( const string &  confusion_file_name) const

Definition at line 2975 of file testing_analysis.cpp.

◆ save_misclassified_samples()

void save_misclassified_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels,
const string &  misclassified_samples_file_name 
)

Definition at line 3258 of file testing_analysis.cpp.

◆ save_misclassified_samples_probability_histogram() [1/2]

void save_misclassified_samples_probability_histogram ( const Tensor< string, 2 > &  misclassified_samples,
const string &  histogram_file_name 
)

Definition at line 3392 of file testing_analysis.cpp.

◆ save_misclassified_samples_probability_histogram() [2/2]

void save_misclassified_samples_probability_histogram ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels,
const string &  histogram_file_name 
)

Definition at line 3371 of file testing_analysis.cpp.

◆ save_misclassified_samples_statistics()

void save_misclassified_samples_statistics ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels,
const string &  statistics_file_name 
)

Definition at line 3308 of file testing_analysis.cpp.

◆ save_multiple_classification_tests()

void save_multiple_classification_tests ( const string &  classification_tests_file_name) const

Definition at line 3019 of file testing_analysis.cpp.

◆ save_well_classified_samples()

void save_well_classified_samples ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels,
const string &  well_classified_samples_file_name 
)

Definition at line 3236 of file testing_analysis.cpp.

◆ save_well_classified_samples_probability_histogram() [1/2]

void save_well_classified_samples_probability_histogram ( const Tensor< string, 2 > &  well_classified_samples,
const string &  histogram_file_name 
)

Definition at line 3355 of file testing_analysis.cpp.

◆ save_well_classified_samples_probability_histogram() [2/2]

void save_well_classified_samples_probability_histogram ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels,
const string &  histogram_file_name 
)

Definition at line 3334 of file testing_analysis.cpp.

◆ save_well_classified_samples_statistics()

void save_well_classified_samples_statistics ( const Tensor< type, 2 > &  targets,
const Tensor< type, 2 > &  outputs,
const Tensor< string, 1 > &  labels,
const string &  statistics_file_name 
)

Definition at line 3280 of file testing_analysis.cpp.

◆ set_data_set_pointer()

void 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 145 of file testing_analysis.cpp.

◆ set_default()

void set_default ( )

Sets some default values to the testing analysis object:

  • Display: True.

Definition at line 112 of file testing_analysis.cpp.

◆ set_display()

void 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 156 of file testing_analysis.cpp.

◆ set_neural_network_pointer()

void 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 136 of file testing_analysis.cpp.

◆ set_threads_number()

void set_threads_number ( const int &  new_threads_number)

Definition at line 123 of file testing_analysis.cpp.

◆ write_XML()

void write_XML ( tinyxml2::XMLPrinter file_stream) const
virtual

Serializes the testing analysis object into a XML document of the TinyXML library without keep the DOM tree in memory. See the OpenNN manual for more information about the format of this document.

Definition at line 3950 of file testing_analysis.cpp.

Member Data Documentation

◆ data_set_pointer

DataSet* data_set_pointer = nullptr
private

Pointer to a data set object.

Definition at line 347 of file testing_analysis.h.

◆ display

bool display = true
private

Display messages to screen.

Definition at line 351 of file testing_analysis.h.

◆ neural_network_pointer

NeuralNetwork* neural_network_pointer = nullptr
private

Pointer to the neural network object to be tested.

Definition at line 343 of file testing_analysis.h.

◆ non_blocking_thread_pool

NonBlockingThreadPool* non_blocking_thread_pool = nullptr
private

Definition at line 338 of file testing_analysis.h.

◆ SSE

const Eigen::array<IndexPair<Index>, 2> SSE = {IndexPair<Index>(0, 0), IndexPair<Index>(1, 1)}
private

Definition at line 353 of file testing_analysis.h.

◆ thread_pool_device

ThreadPoolDevice* thread_pool_device = nullptr
private

Definition at line 339 of file testing_analysis.h.


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