exarl.candlelib.viz_utils

Module Contents

Functions

plot_history(out, history, metric='loss', title=None, width=8, height=6)

plot_scatter(data, classes, out, width=10, height=8)

plot_error(y_true, y_pred, batch, file_ext, file_pre='output_dir', subsample=1000)

plot_density_observed_vs_predicted(Ytest, Ypred, pred_name=None, figprefix=None)

Functionality to plot a 2D histogram of the distribution of observed (ground truth)

plot_2d_density_sigma_vs_error(sigma, yerror, method=None, figprefix=None)

Functionality to plot a 2D histogram of the distribution of

plot_histogram_error_per_sigma(sigma, yerror, method=None, figprefix=None)

Functionality to plot a 1D histogram of the distribution of

plot_calibration_and_errors(mean_sigma, sigma_start_index, sigma_end_index, min_sigma, max_sigma, error_thresholds, error_thresholds_smooth, err_err, s_interpolate, coverage_percentile, method=None, figprefix=None, steps=False)

Functionality to plot empirical calibration curves

plot_percentile_predictions(Ypred, Ypred_Lp, Ypred_Hp, percentile_list, pred_name=None, figprefix=None)

Functionality to plot the mean of the percentiles predicted.

plot_metrics(history, title=None, skip_ep=0, outdir='.', add_lr=False)

Plots keras training curves history.

exarl.candlelib.viz_utils.plot_history(out, history, metric='loss', title=None, width=8, height=6)
exarl.candlelib.viz_utils.plot_scatter(data, classes, out, width=10, height=8)
exarl.candlelib.viz_utils.plot_error(y_true, y_pred, batch, file_ext, file_pre='output_dir', subsample=1000)
exarl.candlelib.viz_utils.plot_density_observed_vs_predicted(Ytest, Ypred, pred_name=None, figprefix=None)

Functionality to plot a 2D histogram of the distribution of observed (ground truth) values vs. predicted values. The plot generated is stored in a png file.

Parameters
  • Ytest (numpy array) – Array with (true) observed values

  • Ypred (numpy array) – Array with predicted values.

  • pred_name (string) – Name of data colum or quantity predicted (e.g. growth, AUC, etc.)

  • figprefix (string) – String to prefix the filename to store the figure generated. A ‘_density_predictions.png’ string will be appended to the figprefix given.

exarl.candlelib.viz_utils.plot_2d_density_sigma_vs_error(sigma, yerror, method=None, figprefix=None)

Functionality to plot a 2D histogram of the distribution of the standard deviations computed for the predictions vs. the computed errors (i.e. values of observed - predicted). The plot generated is stored in a png file.

Parameters
  • sigma (numpy array) – Array with standard deviations computed.

  • yerror (numpy array) – Array with errors computed (observed - predicted).

  • method (string) – Method used to compute the standard deviations (i.e. dropout, heteroscedastic, etc.).

  • figprefix (string) – String to prefix the filename to store the figure generated. A ‘_density_sigma_error.png’ string will be appended to the figprefix given.

exarl.candlelib.viz_utils.plot_histogram_error_per_sigma(sigma, yerror, method=None, figprefix=None)

Functionality to plot a 1D histogram of the distribution of computed errors (i.e. values of observed - predicted) observed for specific values of standard deviations computed. The range of standard deviations computed is split in xbins values and the 1D histograms of error distributions for the smallest six standard deviations are plotted. The plot generated is stored in a png file.

Parameters
  • sigma (numpy array) – Array with standard deviations computed.

  • yerror (numpy array) – Array with errors computed (observed - predicted).

  • method (string) – Method used to comput the standard deviations (i.e. dropout, heteroscedastic, etc.).

  • figprefix (string) – String to prefix the filename to store the figure generated. A ‘_histogram_error_per_sigma.png’ string will be appended to the figprefix given.

exarl.candlelib.viz_utils.plot_calibration_and_errors(mean_sigma, sigma_start_index, sigma_end_index, min_sigma, max_sigma, error_thresholds, error_thresholds_smooth, err_err, s_interpolate, coverage_percentile, method=None, figprefix=None, steps=False)

Functionality to plot empirical calibration curves estimated by binning the statistics of computed standard deviations and errors.

Parameters
  • mean_sigma (numpy array) – Array with the mean standard deviations computed per bin.

  • sigma_start_index (non-negative integer) – Index of the mean_sigma array that defines the start of the valid empirical calibration interval (i.e. index to the smallest std for which a meaningful error is obtained).

  • sigma_end_index (non-negative integer) – Index of the mean_sigma array that defines the end of the valid empirical calibration interval (i.e. index to the largest std for which a meaningful error is obtained).

  • min_sigma (numpy array) – Array with the minimum standard deviations computed per bin.

  • max_sigma (numpy array) – Array with the maximum standard deviations computed per bin.

  • error_thresholds (numpy array) – Thresholds of the errors computed to attain a certain error coverage per bin.

  • error_thresholds_smooth (numpy array) – Thresholds of the errors computed to attain a certain error coverage per bin after a smoothed operation is applied to the frequently noisy bin-based estimations.

  • err_err (numpy array) – Vertical error bars (usually one standard deviation for a binomial distribution estimated by bin) for the error calibration computed empirically.

  • s_interpolate (scipy.interpolate python object) – A python object from scipy.interpolate that computes a univariate spline (InterpolatedUnivariateSpline) constructed to express the mapping from standard deviation to error. This spline is generated during the computational empirical calibration procedure.

  • coverage_percentile (float) – Value used for the coverage in the percentile estimation of the observed error.

  • method (string) – Method used to comput the standard deviations (i.e. dropout, heteroscedastic, etc.).

  • figprefix (string) – String to prefix the filename to store the figure generated. A ‘_empirical_calibration.png’ string will be appended to the figprefix given.

  • steps (boolean) – Besides the complete empirical calibration (including raw statistics, error bars and smoothing), also generates partial plots with only the raw bin statistics (step1) and with only the raw bin statistics and the smoothing interpolation (step2).

exarl.candlelib.viz_utils.plot_percentile_predictions(Ypred, Ypred_Lp, Ypred_Hp, percentile_list, pred_name=None, figprefix=None)

Functionality to plot the mean of the percentiles predicted. The plot generated is stored in a png file.

Parameters
  • Ypred (numpy array) – Array with mid percentile predicted values.

  • Ypred_Lp (numpy array) – Array with low percentile predicted values.

  • Ypred_Hp (numpy array) – Array with high percentile predicted values.

  • percentile_list (string list) – List of percentiles predicted (e.g. ‘10p’, ‘90p’, etc.)

  • pred_name (string) – Name of data colum or quantity predicted (e.g. growth, AUC, etc.)

  • figprefix (string) – String to prefix the filename to store the figure generated. A ‘_density_predictions.png’ string will be appended to the figprefix given.

exarl.candlelib.viz_utils.plot_metrics(history, title=None, skip_ep=0, outdir='.', add_lr=False)

Plots keras training curves history.

Parameters
  • history (history object) –

  • title (str) – Title for plot

  • skip_ep (integer) – number of epochs to skip when plotting metrics

  • outdir (str) – Relative path to output directory

  • add_lr (Boolean) – add curve of learning rate progression over epochs