Module

pycaret.plots.regression

Plotly-native regression diagnostics.

Each function takes a fitted regressor (or Pipeline) plus a holdout set and returns a plotly.graph_objects.Figure.

Usage::

from pycaret.plots import regression as plots
fig = plots.residuals(pipeline, X_test, y_test)
fig.to_dict()  # API JSON payload

Functions 5

residuals(estimator: Any, X: Any, y: Any, title: str | None = 'Residuals vs. predicted') -> go.Figure

Scatter of residuals against predicted values.

A well-fit model shows a horizontal cloud around zero with no pattern. Patterns indicate heteroscedasticity / missed structure.

residuals_distribution(estimator: Any, X: Any, y: Any, nbins: int = 30, title: str | None = 'Residuals distribution') -> go.Figure

Histogram + KDE of residuals; ideal is roughly normal centered at 0.

prediction_error(estimator: Any, X: Any, y: Any, title: str | None = 'Predicted vs. actual') -> go.Figure

Predicted vs. actual scatter with the y=x reference line.

The closer points cluster on the diagonal, the better the fit. R² is annotated when computable.

learning_curve(estimator: Any, X: Any, y: Any, cv: int = 5, train_sizes: np.ndarray | list | None = None, scoring: str = 'r2', title: str | None = 'Learning curve') -> go.Figure

Train + validation score as a function of training set size.

Uses sklearn's learning_curve helper. The estimator is cloned per train-size so the input pipeline isn't mutated.

feature_importance(estimator: Any, feature_names: list[str] | None = None, top_n: int = 20, title: str | None = 'Feature importance') -> go.Figure

Horizontal bar chart of feature importances.

Reads .feature_importances_ (tree models) or .coef_ (linear models). Pipelines are unwrapped to the final estimator.