API Reference¶
Core Explainers¶
|
|
|
Uses Tree SHAP algorithms to explain the output of ensemble tree models. |
|
Explains a model using expected gradients (an extension of integrated gradients). |
|
Meant to approximate SHAP values for deep learning models. |
|
Uses the Kernel SHAP method to explain the output of any function. |
|
This is an extension of the Shapley sampling values explanation method (aka. |
|
|
|
Computes SHAP values for a linear model, optionally accounting for inter-feature correlations. |
|
This method approximates the Shapley values by iterating through permutations of the inputs. |
|
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. |
|
Simply wrap of lime.lime_tabular.LimeTabularExplainer into the common shap interface. |
|
Simply wraps MAPLE into the common SHAP interface. |
|
Simply tree MAPLE into the common SHAP interface. |
Simply returns the global gain/gini feature importances for tree models. |
Plots¶
For usage examples, see Plotting Examples
|
Create a SHAP beeswarm plot, colored by feature values when they are provided. |
|
Visualize model decisions using cumulative SHAP values. |
|
Decision plot for multioutput models. |
|
Create a SHAP dependence plot, colored by an interaction feature. |
|
Visualize the given SHAP values with an additive force layout. |
|
Plots SHAP values for image inputs. |
|
Create a SHAP monitoring plot. |
|
Use the SHAP values as an embedding which we project to 2D for visualization. |
|
A basic partial dependence plot function. |
|
|
|
Plots an explantion of a single prediction as a waterfall plot. |
|
This plots the difference in mean SHAP values between two groups. |
|
Plots an explanation of a string of text using coloring and interactive labels. |
Datasets¶
-
shap.datasets.
a1a
()¶ A sparse dataset in scipy csr matrix format.
-
shap.datasets.
adult
(display=False)¶ Return the Adult census data in a nice package.
-
shap.datasets.
boston
(display=False)¶ Return the boston housing data in a nice package.
-
shap.datasets.
communitiesandcrime
(display=False)¶ 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
-
shap.datasets.
corrgroups60
(display=False)¶ Correlated Groups 60
A simulated dataset with tight correlations among distinct groups of features.
-
shap.datasets.
diabetes
(display=False)¶ 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.
-
shap.datasets.
imdb
(display=False)¶ 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
-
shap.datasets.
independentlinear60
(display=False)¶ A simulated dataset with tight correlations among distinct groups of features.
-
shap.datasets.
iris
(display=False)¶ Return the classic iris data in a nice package.
-
shap.datasets.
linnerud
(display=False)¶ Return the linnerud data in a nice package (multi-target regression).
-
shap.datasets.
nhanesi
(display=False)¶ A nicely packaged version of NHANES I data with surivival times as labels.
-
shap.datasets.
rank
()¶ Ranking datasets from lightgbm repository.