shap.plots.beeswarm

shap.plots.beeswarm(shap_values, max_display=10, order=shap.Explanation.abs.mean(0), clustering=None, cluster_threshold=0.5, color=None, axis_color='#333333', alpha=1, show=True, log_scale=False, color_bar=True, s=16, plot_size='auto', color_bar_label='Feature value')

Create a SHAP beeswarm plot, colored by feature values when they are provided.

Parameters:
shap_valuesExplanation

This is an Explanation object containing a matrix of SHAP values (# samples x # features).

max_displayint

How many top features to include in the plot (default is 10, or 7 for interaction plots).

showbool

Whether matplotlib.pyplot.show() is called before returning. Setting this to False allows the plot to be customized further after it has been created, returning the current axis via plt.gca().

color_barbool

Whether to draw the color bar (legend).

sfloat

What size to make the markers. For further information see s in matplotlib.pyplot.scatter.

plot_size“auto” (default), float, (float, float), or None

What size to make the plot. By default, the size is auto-scaled based on the number of features that are being displayed. Passing a single float will cause each row to be that many inches high. Passing a pair of floats will scale the plot by that number of inches. If None is passed, then the size of the current figure will be left unchanged.

Examples

See beeswarm plot examples.