plot_shap_decision
method plot_shap_decision(models=None, index=None, show=None, target=1, title=None, legend=None, figsize=None, filename=None, display=True)[source]
Plot SHAP's decision plot.
Visualize model decisions using cumulative SHAP values. Each plotted line explains a single model prediction. If a single prediction is plotted, feature values are printed in the plot (if supplied). If multiple predictions are plotted together, feature values will not be printed. Plotting too many predictions together will make the plot unintelligible. Read more about SHAP plots in the user guide.
Parameters | models: int, str, Model or None, default=None
Model to plot. If None, all models are selected. Note that
leaving the default option could raise an exception if there
are multiple models. To avoid this, call the plot directly
from a model, e.g. index: int, str, slice, sequence or None, default=Noneatom.lr.plot_shap_decision() .
Rows in the dataset to plot. If None, it selects all rows
in the test set.
show: int or None, default=None
Number of features (ordered by importance) to show. If
None, it shows all features.
target: int or str, default=1
Class in the target column to look at (only for multi-class
classification tasks).
title: str, dict or None, default=None
Title for the plot.
legend: str, dict or None, default=None
Does nothing. Implemented for continuity of the API.
figsize: tuple or None, default=None
Figure's size in pixels, format as (x, y). If None, it
adapts the size to the number of features shown.
filename: str 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 display: bool or None, default=Truefilename has no file type,
the plot is saved as html. If None, the plot is not saved.
Whether to render the plot. If None, it returns the figure.
|
Returns | plt.Figure or None
Plot object. Only returned if display=None .
|
See Also
Plot SHAP's bar plot.
Plot SHAP's beeswarm plot.
Plot SHAP's force plot.
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)
>>> atom.run("LR")
>>> atom.plot_shap_decision(show=10)
>>> atom.plot_shap_decision(index=-1, show=10)