|
OpenNN
Open-source neural networks library
|
Performs post-training analysis of a neural network: errors, confusion matrices, ROC, gain charts, etc. More...
#include <testing_analysis.h>
Classes | |
| struct | BinaryClassificationRates |
| Sample indices split into the four cells of a binary classification confusion matrix. More... | |
| struct | GoodnessOfFitAnalysis |
| Coefficient of determination and the matching target/output series for a single output variable. More... | |
| struct | KolmogorovSmirnovResults |
| Results of a Kolmogorov-Smirnov analysis: cumulative gains and maximum gain. More... | |
| struct | RocAnalysis |
| Results of a ROC analysis: ROC curve, area under it and optimal threshold. More... | |
Public Member Functions | |
| TestingAnalysis (NeuralNetwork *=nullptr, Dataset *=nullptr) | |
| Constructs the analyser bound to an optional neural network and dataset. | |
| const NeuralNetwork * | get_neural_network () const |
| const Dataset * | get_dataset () const |
| void | set_neural_network (NeuralNetwork *new_neural_network) |
| void | set_dataset (Dataset *new_dataset) |
| void | set_batch_size (Index new_batch_size) |
| Index | get_batch_size () const |
| void | check () const |
| Verifies that the neural network and dataset are consistent for testing analysis. | |
| MatrixR | calculate_error () const |
| Computes the overall error matrix between targets and outputs on the testing samples. | |
| Tensor3 | calculate_error_data () const |
| Computes the per-sample, per-variable error tensor on the testing samples. | |
| MatrixR | calculate_percentage_error_data () const |
| Computes the per-sample percentage error matrix on the testing samples. | |
| vector< Descriptives > | calculate_absolute_errors_descriptives () const |
| Computes descriptive statistics of the absolute errors over the testing samples. | |
| vector< Descriptives > | calculate_absolute_errors_descriptives (const MatrixR &, const MatrixR &) const |
| Computes descriptive statistics of the absolute errors between the supplied targets and outputs. | |
| vector< Descriptives > | calculate_percentage_errors_descriptives () const |
| Computes descriptive statistics of the percentage errors over the testing samples. | |
| vector< Descriptives > | calculate_percentage_errors_descriptives (const MatrixR &, const MatrixR &) const |
| Computes descriptive statistics of the percentage errors between the supplied targets and outputs. | |
| vector< vector< Descriptives > > | calculate_error_data_descriptives () const |
| Computes descriptive statistics of the per-sample error data on the testing samples. | |
| void | print_error_data_descriptives () const |
| Prints the error-data descriptive statistics to stdout. | |
| vector< Histogram > | calculate_error_data_histograms (const Index=10) const |
| Builds histograms of the per-variable error data on the testing samples. | |
| Tensor< VectorI, 1 > | calculate_maximal_errors (const Index=10) const |
| Returns the indices of the samples with the largest errors per output variable. | |
| MatrixR | calculate_errors () const |
| Computes the per-variable error metrics on the testing samples. | |
| VectorR | calculate_errors (const MatrixR &, const MatrixR &) const |
| Computes the error metrics for the supplied targets and outputs. | |
| VectorR | calculate_errors (const string &) const |
| Computes the error metrics for the sample subset with the given role name. | |
| MatrixR | calculate_binary_classification_errors () const |
| Computes binary classification error metrics on the testing samples. | |
| VectorR | calculate_binary_classification_errors (const string &) const |
| Computes binary classification error metrics on the samples with the given role name. | |
| MatrixR | calculate_multiple_classification_errors () const |
| Computes multi-class classification error metrics on the testing samples. | |
| VectorR | calculate_multiple_classification_errors (const string &) const |
| Computes multi-class classification error metrics on the samples with the given role name. | |
| float | calculate_masked_accuracy (const Tensor3 &, const MatrixR &) const |
| Computes accuracy when a masking matrix indicates which tokens to consider (e.g. for language models). | |
| float | calculate_determination (const VectorR &, const VectorR &) const |
| Computes the coefficient of determination R^2 between the supplied target and output series. | |
| Tensor< Correlation, 1 > | linear_correlation (const MatrixR &, const MatrixR &) const |
| Computes the linear correlation between each target/output column pair. | |
| void | print_linear_correlations () const |
| Prints the linear correlations between targets and outputs to stdout. | |
| Tensor< GoodnessOfFitAnalysis, 1 > | perform_goodness_of_fit_analysis () const |
| Performs goodness-of-fit analysis for each output variable. | |
| void | print_goodness_of_fit_analysis () const |
| Prints the goodness-of-fit analysis to stdout. | |
| VectorR | calculate_binary_classification_tests (const float=0.50) const |
| Computes the standard binary classification metrics for the given decision threshold. | |
| void | print_binary_classification_tests () const |
| Prints binary classification metrics to stdout. | |
| vector< MatrixI > | calculate_multilabel_confusion (const float) const |
| Computes per-label binary confusion matrices for multi-label classification. | |
| MatrixI | calculate_confusion (const MatrixR &, const MatrixR &, float=0.50) const |
| Computes the confusion matrix from the supplied targets and outputs. | |
| MatrixI | calculate_confusion (const float=0.50) const |
| Computes the confusion matrix on the testing samples for the given decision threshold. | |
| VectorI | calculate_positives_negatives_rate (const MatrixR &, const MatrixR &) const |
| Counts positives and negatives in targets and outputs (returns TP, FP, FN, TN). | |
| RocAnalysis | perform_roc_analysis () const |
| Performs ROC analysis on the testing samples. | |
| MatrixR | calculate_roc_curve (const MatrixR &, const MatrixR &) const |
| Computes the ROC curve from the supplied targets and outputs. | |
| float | calculate_area_under_curve (const MatrixR &) const |
| Computes the area under the supplied ROC curve. | |
| float | calculate_area_under_curve_confidence_limit (const MatrixR &, const MatrixR &) const |
| Computes the confidence limit of the area under the ROC curve. | |
| float | calculate_optimal_threshold (const MatrixR &) const |
| Computes the decision threshold that maximizes the ROC criterion. | |
| MatrixR | perform_cumulative_gain_analysis () const |
| Performs a cumulative gain analysis on the testing samples. | |
| MatrixR | calculate_cumulative_gain (const MatrixR &, const MatrixR &) const |
| Computes the positive cumulative gain curve from the supplied targets and outputs. | |
| MatrixR | calculate_negative_cumulative_gain (const MatrixR &, const MatrixR &) const |
| Computes the negative cumulative gain curve from the supplied targets and outputs. | |
| MatrixR | perform_lift_chart_analysis () const |
| Performs a lift chart analysis on the testing samples. | |
| MatrixR | calculate_lift_chart (const MatrixR &) const |
| Computes the lift chart from the supplied cumulative gain matrix. | |
| KolmogorovSmirnovResults | perform_Kolmogorov_Smirnov_analysis () const |
| Performs a Kolmogorov-Smirnov analysis on the testing samples. | |
| VectorR | calculate_maximum_gain (const MatrixR &, const MatrixR &) const |
| Computes the maximum gain between positive and negative cumulative gain curves. | |
| vector< Histogram > | calculate_output_histogram (const MatrixR &, Index=10) const |
| Builds histograms of the supplied outputs for the given number of bins. | |
| BinaryClassificationRates | calculate_binary_classification_rates (const float=0.50) const |
| Returns sample indices in the four cells of the binary confusion matrix for the given threshold. | |
| vector< Index > | calculate_true_positive_samples (const MatrixR &, const MatrixR &, const vector< Index > &, float) const |
| Returns the indices of true positive samples given targets, outputs and a candidate index list. | |
| vector< Index > | calculate_false_positive_samples (const MatrixR &, const MatrixR &, const vector< Index > &, float) const |
| Returns the indices of false positive samples given targets, outputs and a candidate index list. | |
| vector< Index > | calculate_false_negative_samples (const MatrixR &, const MatrixR &, const vector< Index > &, float) const |
| Returns the indices of false negative samples given targets, outputs and a candidate index list. | |
| vector< Index > | calculate_true_negative_samples (const MatrixR &, const MatrixR &, const vector< Index > &, float) const |
| Returns the indices of true negative samples given targets, outputs and a candidate index list. | |
| VectorR | calculate_multiple_classification_precision () const |
| Computes the per-class precision for multi-class classification. | |
| MatrixR | calculate_multiple_classification_tests () const |
| Computes the standard multi-class classification metrics. | |
| Tensor< VectorI, 2 > | calculate_multiple_classification_rates () const |
| Returns the per-cell sample indices of the multi-class confusion matrix for the testing samples. | |
| Tensor< VectorI, 2 > | calculate_multiple_classification_rates (const MatrixR &, const MatrixR &, const vector< Index > &) const |
| Returns the per-cell sample indices of the multi-class confusion matrix for the supplied data. | |
| Tensor< string, 2 > | calculate_well_classified_samples (const MatrixR &, const MatrixR &, const vector< string > &) const |
| Returns the well-classified samples annotated with their target and output labels. | |
| Tensor< string, 2 > | calculate_misclassified_samples (const MatrixR &, const MatrixR &, const vector< string > &) const |
| Returns the misclassified samples annotated with their target and output labels. | |
| void | save_confusion (const filesystem::path &) const |
| Saves the confusion matrix of the testing samples to disk. | |
| void | save_multiple_classification_tests (const filesystem::path &) const |
| Saves the multi-class classification metrics of the testing samples to disk. | |
| void | save_well_classified_samples (const MatrixR &, const MatrixR &, const vector< string > &, const filesystem::path &) const |
| Saves the well-classified samples annotated table to disk. | |
| void | save_misclassified_samples (const MatrixR &, const MatrixR &, const vector< string > &, const filesystem::path &) const |
| Saves the misclassified samples annotated table to disk. | |
| void | save_well_classified_samples_statistics (const MatrixR &, const MatrixR &, const vector< string > &, const filesystem::path &) const |
| Saves per-class statistics of the well-classified samples to disk. | |
| void | save_misclassified_samples_statistics (const MatrixR &, const MatrixR &, const vector< string > &, const filesystem::path &) const |
| Saves per-class statistics of the misclassified samples to disk. | |
| vector< VectorR > | calculate_error_autocorrelation (const Index=10) const |
| Computes the autocorrelation of the residual errors up to the given lag. | |
| vector< VectorR > | calculate_inputs_errors_cross_correlation (const Index=10) const |
| Computes the cross-correlation between input variables and residual errors up to the given lag. | |
| pair< float, float > | test_transformer () const |
| Computes loss and accuracy of a transformer model on the testing samples. | |
| string | test_transformer (const vector< string > &context_string, bool imported_vocabulary) const |
| Generates a transformer prediction string from a context. | |
| void | from_JSON (const JsonDocument &) |
| Loads the testing analysis configuration from a JSON document. | |
| void | to_JSON (JsonWriter &) const |
| Writes the testing analysis configuration to a JSON writer. | |
| void | save (const filesystem::path &) const |
| Saves the testing analysis configuration to disk. | |
| void | load (const filesystem::path &) |
| Loads the testing analysis configuration from disk. | |
Performs post-training analysis of a neural network: errors, confusion matrices, ROC, gain charts, etc.
| opennn::TestingAnalysis::TestingAnalysis | ( | NeuralNetwork * | = nullptr, |
| Dataset * | = nullptr ) |
Constructs the analyser bound to an optional neural network and dataset.
| vector< Descriptives > opennn::TestingAnalysis::calculate_absolute_errors_descriptives | ( | ) | const |
Computes descriptive statistics of the absolute errors over the testing samples.
| vector< Descriptives > opennn::TestingAnalysis::calculate_absolute_errors_descriptives | ( | const MatrixR & | , |
| const MatrixR & | ) const |
Computes descriptive statistics of the absolute errors between the supplied targets and outputs.
| float opennn::TestingAnalysis::calculate_area_under_curve | ( | const MatrixR & | ) | const |
Computes the area under the supplied ROC curve.
| float opennn::TestingAnalysis::calculate_area_under_curve_confidence_limit | ( | const MatrixR & | , |
| const MatrixR & | ) const |
Computes the confidence limit of the area under the ROC curve.
| MatrixR opennn::TestingAnalysis::calculate_binary_classification_errors | ( | ) | const |
Computes binary classification error metrics on the testing samples.
| VectorR opennn::TestingAnalysis::calculate_binary_classification_errors | ( | const string & | ) | const |
Computes binary classification error metrics on the samples with the given role name.
| BinaryClassificationRates opennn::TestingAnalysis::calculate_binary_classification_rates | ( | const float | = 0.50 | ) | const |
Returns sample indices in the four cells of the binary confusion matrix for the given threshold.
| VectorR opennn::TestingAnalysis::calculate_binary_classification_tests | ( | const float | = 0.50 | ) | const |
Computes the standard binary classification metrics for the given decision threshold.
| MatrixI opennn::TestingAnalysis::calculate_confusion | ( | const float | = 0.50 | ) | const |
Computes the confusion matrix on the testing samples for the given decision threshold.
| MatrixI opennn::TestingAnalysis::calculate_confusion | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| float | = 0.50 ) const |
Computes the confusion matrix from the supplied targets and outputs.
| MatrixR opennn::TestingAnalysis::calculate_cumulative_gain | ( | const MatrixR & | , |
| const MatrixR & | ) const |
Computes the positive cumulative gain curve from the supplied targets and outputs.
Computes the coefficient of determination R^2 between the supplied target and output series.
| MatrixR opennn::TestingAnalysis::calculate_error | ( | ) | const |
Computes the overall error matrix between targets and outputs on the testing samples.
| vector< VectorR > opennn::TestingAnalysis::calculate_error_autocorrelation | ( | const Index | = 10 | ) | const |
Computes the autocorrelation of the residual errors up to the given lag.
| Tensor3 opennn::TestingAnalysis::calculate_error_data | ( | ) | const |
Computes the per-sample, per-variable error tensor on the testing samples.
| vector< vector< Descriptives > > opennn::TestingAnalysis::calculate_error_data_descriptives | ( | ) | const |
Computes descriptive statistics of the per-sample error data on the testing samples.
| vector< Histogram > opennn::TestingAnalysis::calculate_error_data_histograms | ( | const Index | = 10 | ) | const |
Builds histograms of the per-variable error data on the testing samples.
| MatrixR opennn::TestingAnalysis::calculate_errors | ( | ) | const |
Computes the per-variable error metrics on the testing samples.
Computes the error metrics for the supplied targets and outputs.
| VectorR opennn::TestingAnalysis::calculate_errors | ( | const string & | ) | const |
Computes the error metrics for the sample subset with the given role name.
| vector< Index > opennn::TestingAnalysis::calculate_false_negative_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< Index > & | , | ||
| float | ) const |
Returns the indices of false negative samples given targets, outputs and a candidate index list.
| vector< Index > opennn::TestingAnalysis::calculate_false_positive_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< Index > & | , | ||
| float | ) const |
Returns the indices of false positive samples given targets, outputs and a candidate index list.
| vector< VectorR > opennn::TestingAnalysis::calculate_inputs_errors_cross_correlation | ( | const Index | = 10 | ) | const |
Computes the cross-correlation between input variables and residual errors up to the given lag.
Computes the lift chart from the supplied cumulative gain matrix.
| float opennn::TestingAnalysis::calculate_masked_accuracy | ( | const Tensor3 & | , |
| const MatrixR & | ) const |
Computes accuracy when a masking matrix indicates which tokens to consider (e.g. for language models).
| Tensor< VectorI, 1 > opennn::TestingAnalysis::calculate_maximal_errors | ( | const Index | = 10 | ) | const |
Returns the indices of the samples with the largest errors per output variable.
Computes the maximum gain between positive and negative cumulative gain curves.
| Tensor< string, 2 > opennn::TestingAnalysis::calculate_misclassified_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< string > & | ) const |
Returns the misclassified samples annotated with their target and output labels.
| vector< MatrixI > opennn::TestingAnalysis::calculate_multilabel_confusion | ( | const float | ) | const |
Computes per-label binary confusion matrices for multi-label classification.
| MatrixR opennn::TestingAnalysis::calculate_multiple_classification_errors | ( | ) | const |
Computes multi-class classification error metrics on the testing samples.
| VectorR opennn::TestingAnalysis::calculate_multiple_classification_errors | ( | const string & | ) | const |
Computes multi-class classification error metrics on the samples with the given role name.
| VectorR opennn::TestingAnalysis::calculate_multiple_classification_precision | ( | ) | const |
Computes the per-class precision for multi-class classification.
| Tensor< VectorI, 2 > opennn::TestingAnalysis::calculate_multiple_classification_rates | ( | ) | const |
Returns the per-cell sample indices of the multi-class confusion matrix for the testing samples.
| Tensor< VectorI, 2 > opennn::TestingAnalysis::calculate_multiple_classification_rates | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< Index > & | ) const |
Returns the per-cell sample indices of the multi-class confusion matrix for the supplied data.
| MatrixR opennn::TestingAnalysis::calculate_multiple_classification_tests | ( | ) | const |
Computes the standard multi-class classification metrics.
| MatrixR opennn::TestingAnalysis::calculate_negative_cumulative_gain | ( | const MatrixR & | , |
| const MatrixR & | ) const |
Computes the negative cumulative gain curve from the supplied targets and outputs.
| float opennn::TestingAnalysis::calculate_optimal_threshold | ( | const MatrixR & | ) | const |
Computes the decision threshold that maximizes the ROC criterion.
| vector< Histogram > opennn::TestingAnalysis::calculate_output_histogram | ( | const MatrixR & | , |
| Index | = 10 ) const |
Builds histograms of the supplied outputs for the given number of bins.
| MatrixR opennn::TestingAnalysis::calculate_percentage_error_data | ( | ) | const |
Computes the per-sample percentage error matrix on the testing samples.
| vector< Descriptives > opennn::TestingAnalysis::calculate_percentage_errors_descriptives | ( | ) | const |
Computes descriptive statistics of the percentage errors over the testing samples.
| vector< Descriptives > opennn::TestingAnalysis::calculate_percentage_errors_descriptives | ( | const MatrixR & | , |
| const MatrixR & | ) const |
Computes descriptive statistics of the percentage errors between the supplied targets and outputs.
| VectorI opennn::TestingAnalysis::calculate_positives_negatives_rate | ( | const MatrixR & | , |
| const MatrixR & | ) const |
Counts positives and negatives in targets and outputs (returns TP, FP, FN, TN).
Computes the ROC curve from the supplied targets and outputs.
| vector< Index > opennn::TestingAnalysis::calculate_true_negative_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< Index > & | , | ||
| float | ) const |
Returns the indices of true negative samples given targets, outputs and a candidate index list.
| vector< Index > opennn::TestingAnalysis::calculate_true_positive_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< Index > & | , | ||
| float | ) const |
Returns the indices of true positive samples given targets, outputs and a candidate index list.
| Tensor< string, 2 > opennn::TestingAnalysis::calculate_well_classified_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< string > & | ) const |
Returns the well-classified samples annotated with their target and output labels.
| void opennn::TestingAnalysis::check | ( | ) | const |
Verifies that the neural network and dataset are consistent for testing analysis.
| void opennn::TestingAnalysis::from_JSON | ( | const JsonDocument & | ) |
Loads the testing analysis configuration from a JSON document.
|
inline |
|
inline |
|
inline |
| Tensor< Correlation, 1 > opennn::TestingAnalysis::linear_correlation | ( | const MatrixR & | , |
| const MatrixR & | ) const |
Computes the linear correlation between each target/output column pair.
| void opennn::TestingAnalysis::load | ( | const filesystem::path & | ) |
Loads the testing analysis configuration from disk.
| MatrixR opennn::TestingAnalysis::perform_cumulative_gain_analysis | ( | ) | const |
Performs a cumulative gain analysis on the testing samples.
| Tensor< GoodnessOfFitAnalysis, 1 > opennn::TestingAnalysis::perform_goodness_of_fit_analysis | ( | ) | const |
Performs goodness-of-fit analysis for each output variable.
| KolmogorovSmirnovResults opennn::TestingAnalysis::perform_Kolmogorov_Smirnov_analysis | ( | ) | const |
Performs a Kolmogorov-Smirnov analysis on the testing samples.
| MatrixR opennn::TestingAnalysis::perform_lift_chart_analysis | ( | ) | const |
Performs a lift chart analysis on the testing samples.
| RocAnalysis opennn::TestingAnalysis::perform_roc_analysis | ( | ) | const |
Performs ROC analysis on the testing samples.
| void opennn::TestingAnalysis::print_binary_classification_tests | ( | ) | const |
Prints binary classification metrics to stdout.
| void opennn::TestingAnalysis::print_error_data_descriptives | ( | ) | const |
Prints the error-data descriptive statistics to stdout.
| void opennn::TestingAnalysis::print_goodness_of_fit_analysis | ( | ) | const |
Prints the goodness-of-fit analysis to stdout.
| void opennn::TestingAnalysis::print_linear_correlations | ( | ) | const |
Prints the linear correlations between targets and outputs to stdout.
| void opennn::TestingAnalysis::save | ( | const filesystem::path & | ) | const |
Saves the testing analysis configuration to disk.
| void opennn::TestingAnalysis::save_confusion | ( | const filesystem::path & | ) | const |
Saves the confusion matrix of the testing samples to disk.
| void opennn::TestingAnalysis::save_misclassified_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< string > & | , | ||
| const filesystem::path & | ) const |
Saves the misclassified samples annotated table to disk.
| void opennn::TestingAnalysis::save_misclassified_samples_statistics | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< string > & | , | ||
| const filesystem::path & | ) const |
Saves per-class statistics of the misclassified samples to disk.
| void opennn::TestingAnalysis::save_multiple_classification_tests | ( | const filesystem::path & | ) | const |
Saves the multi-class classification metrics of the testing samples to disk.
| void opennn::TestingAnalysis::save_well_classified_samples | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< string > & | , | ||
| const filesystem::path & | ) const |
Saves the well-classified samples annotated table to disk.
| void opennn::TestingAnalysis::save_well_classified_samples_statistics | ( | const MatrixR & | , |
| const MatrixR & | , | ||
| const vector< string > & | , | ||
| const filesystem::path & | ) const |
Saves per-class statistics of the well-classified samples to disk.
|
inline |
|
inline |
|
inline |
| pair< float, float > opennn::TestingAnalysis::test_transformer | ( | ) | const |
Computes loss and accuracy of a transformer model on the testing samples.
| string opennn::TestingAnalysis::test_transformer | ( | const vector< string > & | context_string, |
| bool | imported_vocabulary ) const |
Generates a transformer prediction string from a context.
| context_string | Tokenized context for the model. |
| imported_vocabulary | True if the vocabulary was imported from outside the dataset. |
| void opennn::TestingAnalysis::to_JSON | ( | JsonWriter & | ) | const |
Writes the testing analysis configuration to a JSON writer.