OSS TanbouSign in with GitHub

Decompose predictions into feature contributions to inspect model behavior

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
25,794
Primary language
Jupyter Notebook
License
MIT
Repository last updated
Oct 4, 2026
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.

Sources: [1][3][4]

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.

Sources: [1][2][5][6]

Official sources

  1. [1]SHAP v0.52.0 README(2026-10-04)
  2. [2]SHAP v0.52.0 package metadata(2026-10-04)
  3. [3]SHAP v0.52.0 Explainer implementation(2026-10-04)
  4. [4]SHAP v0.52.0 ExactExplainer implementation(2026-10-04)
  5. [5]shap/shap GitHub repository metadata(2026-10-04)
  6. [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. 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. 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. 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
Check the official README

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

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
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?