Module

pycaret.plots.feature

Plotly-native feature attribution plots — model-agnostic.

Built on sklearn primitives (permutation_importance, partial_dependence) so they work with any fitted estimator without requiring SHAP. SHAP-based plots will be added as an optional layer (install via pip install pycaret[explain]).

Functions:

  • permutation_importance — drop-in replacement for the legacy feature-importance plot, but works on any model (not just trees).
  • partial_dependence — 1-D / 2-D PDP showing how the model output changes with one or two features.
  • ice_curve — individual conditional expectation; per-row PDP trajectories with the average overlaid.

Functions 5

permutation_importance(estimator: Any, X: Any, y: Any, feature_names: list[str] | None = None, n_repeats: int = 10, random_state: int | None = 0, scoring: str | None = None, top_n: int = 20, title: str | None = 'Permutation feature importance') -> go.Figure

Model-agnostic feature importance via sklearn's permutation_importance.

Each feature is permuted n_repeats times; the drop in score is its importance. Returns a horizontal bar chart with error bars (±σ across repeats).

Parameters#

estimator : fitted model or Pipeline X, y : holdout data + true labels / values feature_names : column names in the order X columns appear n_repeats : permutation repeats per feature (default 10) scoring : sklearn scorer string; defaults to the estimator's task top_n : how many features to show

partial_dependence(estimator: Any, X: Any, feature: str | int | tuple, feature_names: list[str] | None = None, grid_resolution: int = 50, kind: str = 'average', title: str | None = None) -> go.Figure

1-D or 2-D partial dependence plot.

Parameters#

estimator : fitted classifier / regressor / Pipeline X : data to compute the dependence over (typically X_train) feature : single feature (str / int) for 1-D PDP; tuple of two for 2-D. feature_names : column names; auto-derived from a DataFrame grid_resolution : how many grid points along each axis kind : "average" (PDP) | "individual" (ICE) | "both"

ice_curve(estimator: Any, X: Any, feature: str | int, feature_names: list[str] | None = None, grid_resolution: int = 50, centered: bool = False, sample: int | None = 100, random_state: int = 0, title: str | None = None) -> go.Figure

Individual Conditional Expectation: per-row PDP trajectories.

More transparent than a simple PDP because it shows interactions — if ICE curves are non-parallel the model has interaction effects on that feature.

Parameters#

centered : if True, subtract each curve's first value (c-ICE). sample : take this many random rows; None for all.

shap_summary(estimator: Any, X: Any, feature_names: list[str] | None = None, sample: int | None = 200, random_state: int = 0, title: str | None = 'SHAP feature importance') -> go.Figure

Mean |SHAP value| per feature — bar chart.

Soft-dep on shap. Falls back to a clear ImportError if shap isn't available; UI side should hide / disable the chart card in that case.

shap_beeswarm(estimator: Any, X: Any, feature_names: list[str] | None = None, sample: int | None = 200, random_state: int = 0, top_n: int = 12, title: str | None = 'SHAP beeswarm') -> go.Figure

Per-row SHAP values colored by feature value, sorted by importance.

Soft-dep on shap.