Skip to content

waterfall_plot


method waterfall_plot(models=None, index=None, show=None, target=1, title=None, figsize=None, filename=None, display=True, **kwargs) [source]

Plot SHAP's waterfall plot for a single prediction. The SHAP value of a feature represents the impact of the evidence provided by that feature on the model’s output. The waterfall plot is designed to visually display how the SHAP values (evidence) of each feature move the model output from our prior expectation under the background data distribution, to the final model prediction given the evidence of all the features. Features are sorted by the magnitude of their SHAP values with the smallest magnitude features grouped together at the bottom of the plot when the number of features in the models exceeds the show parameter. Read more about SHAP plots in the user guide.

Parameters:

models: str, sequence or None, optional (default=None)
Name of the model to plot. If None, all models in the pipeline are selected. Note that leaving the default option could raise an exception if there are multiple models in the pipeline. To avoid this, call the plot from a model, e.g. atom.xgb.waterfall_plot().

index: int, str or None, optional (default=None)
Index or position of the row in the dataset to plot. If None, it selects the first row in the test set. The waterfall plot does not support plotting multiple samples.

show: int or None, optional (default=None)
Number of features to show in the plot. None to show all.

target: int or str, optional (default=1)
Index or name of the class in the target column to look at. Only for multi-class classification tasks.

title: str or None, optional (default=None)
Plot's title. If None, the title is left empty.

figsize: tuple or None, optional (default=None)
Figure's size, format as (x, y). If None, it adapts the size to the number of features shown.

filename: str or None, optional (default=None)
Name of the file. Use "auto" for automatic naming. If None, the figure is not saved.

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

Returns: matplotlib.figure.Figure
Plot object. Only returned if display=None.


Example

from atom import ATOMClassifier

atom = ATOMClassifier(X, y)
atom.run("Tree")
atom.tree.waterfall_plot(index=120)
waterfall_plot
Back to top