Skip to content

plot_parshap


method plot_parshap(models=None, columns=None, target=1, title=None, legend="upper left", figsize=(900, 600), filename=None, display=True)[source]
Plot the partial correlation of shap values.

Plots the train and test correlation between the shap value of every feature with its target value, after removing the effect of all other features (partial correlation). This plot is useful to identify the features that are contributing most to overfitting. Features that lie below the bisector (diagonal line) performed worse on the test set than on the training set. If the estimator has a scores_, feature_importances_ or coef_ attribute, its normalized values are shown in a color map. This plot is not available for forecast tasks.

Parametersmodels: int, str, Model, segment, sequence or None, default=None
Models to plot. If None, all models are selected.

columns: int, str, segment, sequence, dataframe or None, default=None
Feature set to plot. If None, it selects all features.

target: int, str or tuple, default=1
Class in the target column to target. For multioutput tasks, the value should be a tuple of the form (column, class). Note that for binary and multilabel tasks, the selected class is always the positive one.

title: str, dict or None, default=None
Title for the plot.

legend: str, dict or None, default="upper left"
Legend for the plot. See the user guide for an extended description of the choices.

  • If None: No legend is shown.
  • If str: Position to display the legend.
  • If dict: Legend configuration.

figsize: tuple, default=(900, 600)
Figure's size in pixels, format as (x, y).

filename: str, Path or None, default=None
Save the plot using this name. Use "auto" for automatic naming. The type of the file depends on the provided name (.html, .png, .pdf, etc...). If filename has no file type, the plot is saved as html. If None, the plot is not saved.

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

Returnsgo.Figure or None
Plot object. Only returned if display=None.


See Also

plot_feature_importance

Plot a model's feature importance.

plot_partial_dependence

Plot the partial dependence of features.

plot_permutation_importance

Plot the feature permutation importance of models.


Example

>>> from atom import ATOMClassifier
>>> from sklearn.datasets import load_breast_cancer

>>> X, y = load_breast_cancer(return_X_y=True, as_frame=True)

>>> atom = ATOMClassifier(X, y, random_state=1)
>>> atom.run(["GNB", "RF"])
>>> atom.rf.plot_parshap(legend=None)

>>> atom.plot_parshap(columns=slice(5, 10))