Skip to content

bar_plot


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

Plot SHAP's bar plot. Create a bar plot of a set of SHAP values. If a single sample is passed, then the SHAP values are plotted. If many samples are passed, then the mean absolute value for each feature column is plotted. 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.bar_plot().

index: int, tuple, slice or None, optional (default=None)
Indices of the rows in the dataset to plot. If tuple (n, m), it selects rows n until m. If None, it selects all rows in the test set.

show: int or None, optional (default=None)
Number of features (ordered by importance) to show. 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.

**kwargs
Additional keyword arguments for SHAP's bar plot.

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


Example

from atom import ATOMRegressor

atom = ATOMRegressor(X, y)
atom.run("RF")
atom.bar_plot()  # For multiple samples
bar_plot_1


atom.bar_plot(index=120)  # For a single sample

bar_plot_2
Back to top