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)

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.

showbool

If show is set to False then we don’t call the matplotlib.pyplot.show() function. This allows further customization of the plot by the caller after the bar() function is finished.