SHAP assigns per-feature contributions that explain individual model outputs using Shapley additive explanations. Python explainers cover trees, deep nets, linear models, and arbitrary black-box functions.
Overview
SHAP is a Python package that explains what drives each prediction from a trained model by allocating credit across input features. It frames explanations as Shapley values from cooperative game theory, linking global importance with local, per-sample attributions.
Specialized explainers speed up exact tree ensemble cases for XGBoost, LightGBM, CatBoost, scikit-learn, and PySpark models. DeepExplainer and GradientExplainer target TensorFlow and Keras networks, with preliminary PyTorch support, while LinearExplainer yields closed-form attributions for independent linear models.
KernelExplainer provides a model-agnostic route for any callable predictor, and extensions cover NLP transformers, interaction values for pairwise feature effects, and visualization helpers such as force, dependence, decision, and summary plots. Optional GPU acceleration for tree SHAP arrives through a companion cuda extra package.
Installation is available from PyPI or conda-forge, and documentation walks through tabular, text, image, and genomics examples alongside API references for explainers, plots, and masking utilities.
Key features
- Tree SHAP for ensemble models
- Deep and gradient explainers for neural nets
- Kernel SHAP for any predictor
- Transformer and NLP pipeline support
- Interaction value computation
- Summary, force, and dependence plots
- Optional GPU tree explainer extra
- PyPI and conda-forge installs
Use cases
- Explaining individual classification scores
- Ranking global feature importance
- Auditing tree model risk factors
- Interpreting deep learning image outputs
- Analyzing NLP model token contributions