Skip to content

plot_residuals


method plot_residuals(models=None, dataset="test", title=None, figsize=(10, 6), filename=None, display=True) [source]

The plot shows the residuals (difference between the predicted and the true value) on the vertical axis and the independent variable on the horizontal axis. The gray, intersected line shows the identity line. This plot can be useful to analyze the variance of the error of the regressor. If the points are randomly dispersed around the horizontal axis, a linear regression model is appropriate for the data; otherwise, a non-linear model is more appropriate. Only for regression tasks.

Parameters:

models: str, sequence or None, optional (default=None)
Name of the models to plot. If None, all models in the pipeline are selected.

dataset: str, optional (default="test")
Data set on which to calculate the residuals. Choose from: "train", "test", "both" (train and test) or "holdout".

title: str or None, optional (default=None)
Plot's title. If None, the title is left empty.

figsize: tuple, optional (default=(10, 6))
Figure's size, format as (x, y).

filename: str or None, optional (default=None)
Name of the file. Use "auto" for automatic naming. If None, the figure is not saved.

display: bool or None, optional (default=True)
Whether to render the plot. If None, it returns the matplotlib figure.

Returns: matplotlib.figure.Figure
Plot object. Only returned if display=None.


Example

from atom import ATOMRegressor

atom = ATOMRegressor(X, y)
atom.run(["OLS", "LGB"], metric="MAE")
atom.plot_residuals()
plot_residuals
Back to top