shap.plots.heatmap

shap.plots.heatmap(shap_values, instance_order=shap.Explanation.hclust, feature_values=shap.Explanation.abs.mean(0), feature_order=None, max_display=10, cmap=<matplotlib.colors.LinearSegmentedColormap object>, show=True, plot_width=8)

Create a heatmap plot of a set of SHAP values.

This plot is designed to show the population substructure of a dataset using supervised clustering and a heatmap. Supervised clustering involves clustering data points not by their original feature values but by their explanations. By default, we cluster using shap.utils.hclust_ordering(), but any clustering can be used to order the samples.

Parameters:
shap_valuesshap.Explanation

A multi-row Explanation object that we want to visualize in a cluster ordering.

instance_orderOpChain or numpy.ndarray

A function that returns a sort ordering given a matrix of SHAP values and an axis, or a direct sample ordering given as an numpy.ndarray.

feature_valuesOpChain or numpy.ndarray

A function that returns a global summary value for each input feature, or an array of such values.

feature_orderNone, OpChain, or numpy.ndarray

A function that returns a sort ordering given a matrix of SHAP values and an axis, or a direct input feature ordering given as an numpy.ndarray. If None, then we use feature_values.argsort.

max_displayint

The maximum number of features to display (default is 10).

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.

plot_width: int, default 8

The width of the heatmap plot.

Examples

See heatmap plot examples.