API Reference

Core Explainers

shap.Explainer(model, masker[, link, …])

shap.TreeExplainer(model[, data, …])

Uses Tree SHAP algorithms to explain the output of ensemble tree models.

shap.GradientExplainer(model, data[, …])

Explains a model using expected gradients (an extension of integrated gradients).

shap.DeepExplainer(model, data[, session, …])

Meant to approximate SHAP values for deep learning models.

shap.KernelExplainer(model, data[, link])

Uses the Kernel SHAP method to explain the output of any function.

shap.SamplingExplainer(model, data, **kwargs)

This is an extension of the Shapley sampling values explanation method (aka.

shap.PartitionExplainer(model, masker, *[, …])

shap.LinearExplainer(model, data[, …])

Computes SHAP values for a linear model, optionally accounting for inter-feature correlations.

shap.PermutationExplainer(model, masker[, link])

This method approximates the Shapley values by iterating through permutations of the inputs.

shap.AdditiveExplainer(model, masker)

Computes SHAP values for generalized additive models.

Other Explainers


Simply returns the model coefficents as the feature attributions.


Simply returns random (normally distributed) feature attributions.

shap.explainers.other.LimeTabular(model, data)

Simply wrap of lime.lime_tabular.LimeTabularExplainer into the common shap interface.

shap.explainers.other.Maple(model, data)

Simply wraps MAPLE into the common SHAP interface.

shap.explainers.other.TreeMaple(model, data)

Simply tree MAPLE into the common SHAP interface.


Simply returns the global gain/gini feature importances for tree models.


For usage examples, see Plotting Examples

summary_plot(shap_values[, features, …])

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

decision_plot(base_value, shap_values[, …])

Visualize model decisions using cumulative SHAP values.

multioutput_decision_plot(base_values, …)

Decision plot for multioutput models.

dependence_plot(ind[, shap_values, …])

Create a SHAP dependence plot, colored by an interaction feature.

force_plot(base_value[, shap_values, …])

Visualize the given SHAP values with an additive force layout.

image_plot(shap_values[, pixel_values, …])

Plots SHAP values for image inputs.

monitoring_plot(ind, shap_values, features)

Create a SHAP monitoring plot.

embedding_plot(ind, shap_values[, …])

Use the SHAP values as an embedding which we project to 2D for visualization.

partial_dependence_plot(ind, model, data[, …])

A basic partial dependence plot function.

bar_plot(shap_values[, features, …])

waterfall_plot(shap_values[, max_display, show])

Plots an explantion of a single prediction as a waterfall plot.

group_difference_plot(shap_values, group_mask)

This plots the difference in mean SHAP values between two groups.

text_plot(shap_values[, …])

Plots an explanation of a string of text using coloring and interactive labels.



A sparse dataset in scipy csr matrix format.


Return the Adult census data in a nice package.


Return the boston housing data in a nice package.


Predict total number of non-violent crimes per 100K popuation.

This dataset is from the classic UCI Machine Learning repository: https://archive.ics.uci.edu/ml/datasets/Communities+and+Crime+Unnormalized


Correlated Groups 60

A simulated dataset with tight correlations among distinct groups of features.


Return the diabetes data in a nice package.

shap.datasets.imagenet50(display=False, resolution=224)

This is a set of 50 images representative of ImageNet images.

This dataset was collected by randomly finding a working ImageNet link and then pasting the original ImageNet image into Google image search restricted to images licensed for reuse. A similar image (now with rights to reuse) was downloaded as a rough replacment for the original ImageNet image. The point is to have a random sample of ImageNet for use as a background distribution for explaining models trained on ImageNet data.

Note that because the images are only rough replacements the labels might no longer be correct.


Return the clssic IMDB sentiment analysis training data in a nice package.

Full data is at: http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz Paper to cite when using the data is: http://www.aclweb.org/anthology/P11-1015


A simulated dataset with tight correlations among distinct groups of features.


Return the classic iris data in a nice package.


Return the linnerud data in a nice package (multi-target regression).


A nicely packaged version of NHANES I data with surivival times as labels.


Ranking datasets from lightgbm repository.