On this page
Overview
SHAP is a Python library that uses game-theoretic Shapley values to decompose machine-learning outputs into feature contributions. A common Explanation structure supports both the factors pushing one prediction up or down and feature importance across a dataset.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Obtain common attribution data from model-specific explainers
shap.Explainer selects an explainer from a model and background data, then stores feature values, base values, and input data in an Explanation. TreeExplainer targets tree models, DeepExplainer handles deep-learning approximations, and ExactExplainer or KernelExplainer can cover model-agnostic cases; waterfall, beeswarm, and scatter plots consume the results.
Best fit
Move between individual decisions and dataset-wide patterns
It fits investigations that trace one mistaken prediction in a waterfall plot and then scan many rows for bias or missing signals in a beeswarm plot. Comparing contribution direction and magnitude between model versions can reveal behavioral changes that aggregate accuracy does not show.
Sources: [1]
Before adoption
State the background, computation cost, and causal boundary
Attributions depend on the selected background and treatment of features; correlated features do not yield a unique real-world cause. Model-agnostic methods can become expensive as feature counts and evaluations grow, so model-specific explainers are preferable when available. v0.52.0 requires Python 3.12 or newer and NumPy 2 or newer. GitHub reports MIT.
Official sources
- [1]SHAP v0.52.0 README(2026-10-04)
- [2]SHAP v0.52.0 package metadata(2026-10-04)
- [3]SHAP v0.52.0 Explainer implementation(2026-10-04)
- [4]SHAP v0.52.0 ExactExplainer implementation(2026-10-04)
- [5]shap/shap GitHub repository metadata(2026-10-04)
- [6]SHAP v0.52.0 LICENSE(2026-10-04)
Supplemental curator note
Review the background dataset and several representative cases, not only one explained row. SHAP values attribute a model output; they do not establish causality or real-world effects.
Try it in 3 steps
- 1
Create an isolated Python environment
With Python 3.12 or newer in a POSIX shell on macOS or Linux, or in Git Bash or WSL on Windows, create and activate a disposable virtual environment. Continue in the same terminal and working directory.
python3 -m venv shap-demo-env && . shap-demo-env/bin/activate - 2
Install SHAP 0.52.0
Install the fixed release, which requires Python 3.12 or newer and NumPy 2 or newer. This example needs no GPU or external dataset.
python -m pip install "shap==0.52.0" - 3
Verify two feature contributions
Write an LF-terminated one-row, two-feature example with a zero background. Verify that ExactExplainer divides prediction 11 into contributions 3 and 8 with base value 0. Everything runs locally.
printf '%s\n' 'import numpy as np' 'import shap' '' 'background = np.zeros((1, 2))' 'sample = np.array([[3.0, 4.0]])' 'model = lambda values: values[:, 0] + 2 * values[:, 1]' 'explanation = shap.Explainer(model, background, algorithm="exact")(sample)' 'assert np.allclose(explanation.values, [[3.0, 8.0]])' 'assert np.allclose(explanation.base_values, [0.0])' 'print(explanation.values.tolist())' > explain.py && python explain.py
Growth
Growth trends · Last 30 days
25,794 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 29
- Open PRs
- 460
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- interpretability
- machine-learning
- deep-learning
- gradient-boosting
- shap
- shapley
- explainability
- Stars
- 25,794
- Forks
- 3,760
- Watchers
- 246
- Open issues
- 527
- Contributors
- 273
- Owner type
- Organization
- Primary language
- Jupyter Notebook
- License
- MIT
- Repository last updated
- Oct 4, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Streamlit45,893 Stars
2 shared tag(s)
Turn Python scripts into interactive data apps with widgets, dataframes, charts, multipage navigation, and chat
Python - JAX36,374 Stars
1 shared tag(s) · 2 shared category(s)
Compose automatic differentiation, JIT compilation, vectorization, and distributed execution for Python and NumPy-style programs
Python - NLTK14,732 Stars
1 shared tag(s) · 2 shared category(s)
explore NLP with Python modules, corpora, and linguistic analyzers
Python - Evidently7,968 Stars
1 shared tag(s) · 1 shared category(s) · Same language
evaluate and monitor ML, LLM, and data pipelines with 100+ metrics, tests, reports, and an observability UI
Jupyter Notebook - XGBoost28,824 Stars
3 shared tag(s) · 1 shared category(s)
Train gradient-boosted trees for tabular data across CPU, GPU, and distributed environments
C++ - LightGBM18,831 Stars
3 shared tag(s) · 1 shared category(s)
fast and memory-efficient gradient-boosted trees at scale
C++
Report incorrect information
Tell us if any listing information is incorrect or outdated.