Error

class mastml.plots.Error[source]

Bases: object

Class to make plots related to model error assessment and uncertainty quantification

Args:

None

Methods:
plot_normalized_error: Method to plot the normalized residual errors of a model prediction
Args:

residuals: (pd.Series), series containing the true errors (model residuals)

savepath: (str), string denoting the save path to save the figure to

data_type: (str), string denoting the data type, e.g. train, test, leftout

model_errors: (pd.Series), series containing the predicted model errors (optional, default None)

show_figure: (bool), whether or not the generated figure is output to the notebook screen (default False)

Returns:

None

plot_cumulative_normalized_error: Method to plot the cumulative normalized residual errors of a model prediction
Args:

residuals: (pd.Series), series containing the true errors (model residuals)

savepath: (str), string denoting the save path to save the figure to

data_type: (str), string denoting the data type, e.g. train, test, leftout

model_errors: (pd.Series), series containing the predicted model errors (optional, default None)

show_figure: (bool), whether or not the generated figure is output to the notebook screen (default False)

Returns:

None

plot_rstat: Method for plotting the r-statistic distribution (true divided by predicted error)
Args:

savepath: (str), string denoting the save path to save the figure to

data_type: (str), string denoting the data type, e.g. train, test, leftout

residuals: (pd.Series), series containing the true errors (model residuals)

model_errors: (pd.Series), series containing the predicted model errors

show_figure: (bool), whether or not the generated figure is output to the notebook screen (default False)

is_calibrated: (bool), whether or not the model errors have been recalibrated (default False)

Returns:

None

plot_rstat_uncal_cal_overlay: Method for plotting the r-statistic distribution for two cases together: the as-obtained uncalibrated model errors and calibrated errors
Args:

savepath: (str), string denoting the save path to save the figure to

data_type: (str), string denoting the data type, e.g. train, test, leftout

residuals: (pd.Series), series containing the true errors (model residuals)

model_errors: (pd.Series), series containing the predicted model errors

model_errors_cal: (pd.Series), series containing the calibrated predicted model errors

show_figure: (bool), whether or not the generated figure is output to the notebook screen (default False)

Returns:

None

plot_real_vs_predicted_error: Sometimes called the RvE plot, or residual vs. error plot, this method plots the binned RMS residuals as a function of the binned model errors
Args:

savepath: (str), string denoting the save path to save the figure to

model: (mastml.models object), a MAST-ML model object, e.g. SklearnModel or EnsembleModel

data_type: (str), string denoting the data type, e.g. train, test, leftout

model_errors: (pd.Series), series containing the predicted model errors

residuals: (pd.Series), series containing the true errors (model residuals)

dataset_stdev: (float), the standard deviation of the training dataset

show_figure: (bool), whether or not the generated figure is output to the notebook screen (default False)

is_calibrated: (bool), whether or not the model errors have been recalibrated (default False)

well_sampled_fraction: (float), number denoting whether a bin qualifies as well-sampled or not. Default to 0.025 (2.5% of total samples). Only affects visuals, not fitting

Returns:

None

plot_real_vs_predicted_error_uncal_cal_overlay: Method for making the residual vs. error plot for two cases together: using the as-obtained uncalibrated model errors and calibrated errors
Args:

savepath: (str), string denoting the save path to save the figure to

model: (mastml.models object), a MAST-ML model object, e.g. SklearnModel or EnsembleModel

data_type: (str), string denoting the data type, e.g. train, test, leftout

model_errors: (pd.Series), series containing the predicted model errors

model_errors_cal: (pd.Series), series containing the calibrated predicted model errors

residuals: (pd.Series), series containing the true errors (model residuals)

dataset_stdev: (float), the standard deviation of the training dataset

show_figure: (bool), whether or not the generated figure is output to the notebook screen (default False)

well_sampled_fraction: (float), number denoting whether a bin qualifies as well-sampled or not. Default to 0.025 (2.5% of total samples). Only affects visuals, not fitting

Returns:

None

Methods Summary

plot_cumulative_normalized_error(residuals, ...)

plot_normalized_error(residuals, savepath, ...)

plot_real_vs_predicted_error(savepath, ...)

plot_real_vs_predicted_error_uncal_cal_overlay(...)

plot_rstat(savepath, data_type, residuals, ...)

plot_rstat_uncal_cal_overlay(savepath, ...)

Methods Documentation

classmethod plot_cumulative_normalized_error(residuals, savepath, data_type, model_errors=None, show_figure=False, file_extension='.csv', image_dpi=250)[source]
classmethod plot_normalized_error(residuals, savepath, data_type, model_errors=None, show_figure=False, file_extension='.csv', image_dpi=250)[source]
classmethod plot_real_vs_predicted_error(savepath, model, data_type, model_errors, residuals, dataset_stdev, show_figure=False, is_calibrated=False, well_sampled_number=30, image_dpi=250)[source]
classmethod plot_real_vs_predicted_error_uncal_cal_overlay(savepath, model, data_type, model_errors, model_errors_cal, residuals, dataset_stdev, show_figure=False, well_sampled_number=30, image_dpi=250)[source]
classmethod plot_rstat(savepath, data_type, residuals, model_errors, show_figure=False, is_calibrated=False, image_dpi=250)[source]
classmethod plot_rstat_uncal_cal_overlay(savepath, data_type, residuals, model_errors, model_errors_cal, show_figure=False, image_dpi=250)[source]