Code Documentation: Plot Helper¶
mastml.plot_helper Module¶
This module contains a collection of functions which make plots (saved as png files) using matplotlib, generated from some model fits and cross-validation evaluation within a MAST-ML run.
This module also contains a method to create python notebooks containing plotted data and the relevant source code from this module, to enable the user to make their own modifications to the created plots in a straightforward way (useful for tweaking plots for a presentation or publication).
Functions¶
auc (x, y) |
Compute Area Under the Curve (AUC) using the trapezoidal rule. |
ceil |
Return the ceiling of x as an Integral. |
confusion_matrix (y_true, y_pred, *[, …]) |
Compute confusion matrix to evaluate the accuracy of a classification. |
figaspect (arg) |
Calculate the width and height for a figure with a specified aspect ratio. |
floor |
Return the floor of x as an Integral. |
get_divisor (high, low) |
Method to obtain a sensible divisor based on range of two values |
get_histogram_bins (y_df) |
Method to obtain the number of bins to use when plotting a histogram |
ipynb_maker (plot_func) |
This method creates Jupyter Notebooks so user can modify and regenerate the plots produced by MAST-ML. |
join (a, *p) |
Join two or more pathname components, inserting ‘/’ as needed. |
log (x, [base=math.e]) |
Return the logarithm of x to the given base. |
make_axes_locatable (axes) |
|
make_axis_same (ax, max1, min1) |
Method to make the x and y ticks for each axis the same. |
make_error_plots (run, path, …[, groups]) |
|
make_fig_ax ([aspect_ratio, x_align, left]) |
Method to make matplotlib figure and axes objects. |
make_fig_ax_square ([aspect, aspect_ratio]) |
Method to make square shaped matplotlib figure and axes objects. |
make_train_test_plots (run, path, …[, groups]) |
General plotting method used to execute sequence of specific plots of train-test data analysis |
mark_inset (parent_axes, inset_axes, loc1, …) |
Draw a box to mark the location of an area represented by an inset axes. |
nice_mean (ls) |
Method to return mean of a list or equivalent array with NaN values |
nice_names () |
|
nice_range (lower, upper) |
Method to create a range of values, including the specified start and end points, with nicely spaced intervals |
nice_std (ls) |
Method to return standard deviation of a list or equivalent array with NaN values |
parse_error_data (dataset_stdev, …) |
|
plot_1d_heatmap (xs, heats, savepath[, …]) |
Method to plot a heatmap for values of a single variable; used for plotting GridSearch results in hyperparameter optimization. |
plot_2d_heatmap (xs, ys, heats, savepath[, …]) |
Method to plot a heatmap for values of two variables; used for plotting GridSearch results in hyperparameter optimization. |
plot_3d_heatmap (xs, ys, zs, heats, savepath) |
Method to plot a heatmap for values of three variables; used for plotting GridSearch results in hyperparameter optimization. |
plot_average_cumulative_normalized_error (…) |
Method to plot the cumulative normalized residual errors of a model prediction |
plot_average_normalized_error (y_true, …[, …]) |
Method to plot the normalized residual errors of a model prediction |
plot_best_worst_per_point (y_true, …[, …]) |
Method to create a parity plot (predicted vs. |
plot_best_worst_split (y_true, best_run, …) |
Method to create a parity plot (predicted vs. |
plot_confusion_matrix (y_true, y_pred, …[, …]) |
Method used to generate a confusion matrix for a classification run. |
plot_cumulative_normalized_error (y_true, …) |
Method to plot the cumulative normalized residual errors of a model prediction |
plot_keras_history (model_history, savepath, …) |
|
plot_learning_curve (train_sizes, train_mean, …) |
Method used to plot both data and feature learning curves |
plot_learning_curve_convergence (train_sizes, …) |
Method used to plot both the convergence of data and feature learning curves as a function of amount of data or features |
plot_metric_vs_group (metric, groups, stats, …) |
Method to plot the value of a particular calculated metric (e.g. |
plot_metric_vs_group_size (metric, groups, …) |
Method to plot the value of a particular calculated metric (e.g. |
plot_normalized_error (y_true, y_pred, …[, …]) |
Method to plot the normalized residual errors of a model prediction |
plot_precision_recall_curve (y_true, y_pred, …) |
Method to calculate and plot the precision-recall curve for classification model results |
plot_predicted_vs_true (train_quad, …) |
Method to create a parity plot (predicted vs. |
plot_predicted_vs_true_bars (y_true, …[, …]) |
Method to calculate parity plot (predicted vs. |
plot_real_vs_predicted_error (y_true, …) |
|
plot_residuals_histogram (y_true, y_pred, …) |
Method to calculate and plot the histogram of residuals from regression model |
plot_roc_curve (y_true, y_pred, savepath) |
Method to calculate and plot the receiver-operator characteristic curve for classification model results |
plot_scatter (x, y, savepath[, groups, …]) |
Method to create a general scatter plot |
plot_stats (fig, stats[, x_align, y_align, …]) |
Method that prints stats onto the plot. |
plot_target_histogram (y_df, savepath[, …]) |
Method to plot the histogram of true y values |
precision_recall_curve (y_true, probas_pred, *) |
Compute precision-recall pairs for different probability thresholds. |
prediction_intervals (model, X, …) |
Method to calculate prediction intervals when using Random Forest and Gaussian Process regression models. |
r2_score (y_true, y_pred, *[, sample_weight, …]) |
R^2 (coefficient of determination) regression score function. |
recursive_max (arr) |
Method to recursively find the max value of an array of iterables. |
recursive_max_and_min (arr) |
Method to recursively return max and min of values or iterables in array |
recursive_min (arr) |
Method to recursively find the min value of an array of iterables. |
roc_curve (y_true, y_score, *[, pos_label, …]) |
Compute Receiver operating characteristic (ROC). |
round_down (num, divisor) |
Method to return a rounded down number |
round_up (num, divisor) |
Method to return a rounded up number |
rounder (delta) |
Method to obtain number of decimal places to report on plots |
stat_to_string (name, value, nice_names) |
Method that converts a metric object into a string for displaying on a plot |
trim_array (arr_list) |
Method used to trim a set of arrays to make all arrays the same shape |
wraps (wrapped[, assigned, updated]) |
Decorator factory to apply update_wrapper() to a wrapper function |
zoomed_inset_axes (parent_axes, zoom[, loc, …]) |
Create an anchored inset axes by scaling a parent axes. |