Regression Plots#

class PlotPredVsObs(method_name: str, description: str, plot_settings)[source]#

Bases: PlotEvaluator

Plot the predicted vs. observed values for a regression model.

This evaluator creates scatter plots comparing predicted values against observed values for regression models. The plot includes a diagonal reference line (y=x) to help assess model performance, where points closer to this line indicate better predictions.

Attributes:
namestr

The name of the evaluator, set to ‘pred_vs_obs’

plot(model: BaseEstimator, X: DataFrame, y: Series, filename: str) None[source]#

Plot the predicted vs. observed values for a regression model.

Creates a scatter plot comparing predicted values against observed values with a diagonal reference line. Points closer to the diagonal line indicate better model performance.

Parameters:
modelbase.BaseEstimator

The trained regression model to evaluate

Xpd.DataFrame

The input features used for prediction

ypd.Series

The true target values to compare against predictions

filenamestr

The filename to save the plot to

Returns:
None

The plot is saved to the specified filename

class PlotResiduals(method_name: str, description: str, plot_settings)[source]#

Bases: PlotEvaluator

Plot the residuals of a regression model.

This evaluator creates residual plots showing the difference between observed and predicted values. Residual plots help identify patterns in model errors, such as heteroscedasticity or non-linear relationships that the model failed to capture.

Attributes:
namestr

The name of the evaluator, set to ‘residuals’

plot(model: BaseEstimator, X: DataFrame, y: Series, filename: str, add_fit_line: bool = False) None[source]#

Plot the residuals of a regression model.

Creates a scatter plot of residuals (observed - predicted) against observed values. The plot includes a horizontal reference line at y=0 and optionally a trend line to identify patterns in residuals.

Parameters:
modelbase.BaseEstimator

The trained regression model to evaluate

Xpd.DataFrame

The input features used for prediction

ypd.Series

The true target values

filenamestr

The filename to save the plot to

add_fit_linebool, optional

Whether to add a trend line to the residual plot, by default False

Returns:
None

The plot is saved to the specified filename