Skip to content

force_plot


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

Plot SHAP's force plot. Visualize the given SHAP values with an additive force layout. Note that by default this plot will render using javascript. For a regular figure use matplotlib=True (this option is only available when only a single sample 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.force_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.

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, optional (default=(14, 6))
Figure's size, format as (x, y).

filename: str or None, optional (default=None)
Name of the file. If matplotlib=False, the figure is saved as an html file. 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 force plot.

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


Example

from atom import ATOMClassifier

atom = ATOMClassifier(X, y)
atom.run("lr")
atom.force_plot(index=120, matplotlib=True, filename="force_plot")
force_plot
Back to top