skillfed

shap

A unified approach to explain the output of any machine learning model.

shap v0.52.0 19.8M downloads/30d#1,054 on PyPI25,682
Permissive license MIT License Active released

What it is and what it does

SHAP is a model-agnostic explainability library that uses Shapley values from game theory to attribute each feature's contribution to individual model predictions. It works across tree ensembles, transformers, deep learning models, and other architectures, providing both local explanations (why a single prediction was made) and global insights (which features matter most overall).

The library provides multiple visualization methods—waterfall plots, force plots, dependence scatter plots, beeswarm plots, and bar charts—to help interpret model behavior. It includes specialized fast algorithms for tree models and approximation methods for deep learning via DeepExplainer and GradientExplainer. Installation brings 10 runtime dependencies including numpy, scipy, scikit-learn, pandas, tqdm, packaging, slicer, numba, llvmlite, and cloudpickle; GPU support is optional but requires CUDA toolkit and environment setup.

Use it for:

  • Explain individual predictions in production models to stakeholders or for regulatory compliance
  • Debug model behavior by identifying which features drive incorrect or unexpected predictions
  • Compare feature importance across different model types to validate model selection
  • Analyze transformer and NLP model outputs using coalitional Shapley rules for text-based predictions
  • Visualize deep learning model decisions via DeepExplainer for image or tensor-based models

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

SHAP computes Shapley values to explain individual predictions and feature importance across any machine learning model, using game-theoretic attribution to show how each feature contributes to model output.

Yes. SHAP is actively maintained, widely used, has no known vulnerabilities, and uses permissive MIT licensing. Medium install friction is offset by comprehensive pre-built wheels and strong ecosystem support. Install if you need model explainability across any ML framework; skip only if your use case requires minimal dependencies or Python versions below 3.12.

Install

shap on PyPI

pip

pip install shap

uv

uv add shap

poetry

poetry add shap

Installing shap

Before you install

Medium install friction: 10 runtime dependencies including numpy, scipy, scikit-learn, pandas, numba, and llvmlite. Pre-built wheels available for Python 3.12+ across macOS, Linux, and Windows. Active maintenance with recent releases; last commit 2026-08-11.

License in practice

MIT License (permissive): you can use, modify, and distribute SHAP freely in commercial and private projects with minimal restrictions, provided you include the license notice.

Quickstart

pip install shap

import shap

X, y = shap.datasets.california()
explainer = shap.Explainer(model)
shap_values = explainer(X)
shap.plots.waterfall(shap_values[0])

Requires Python >=3.12. GPU-accelerated Tree SHAP requires CUDA toolkit and SHAP_ENABLE_CUDA=1 environment variable set at install time.

Verify before relying

  • Whether GPU acceleration is automatically detected or requires explicit environment setup beyond SHAP_ENABLE_CUDA
  • Performance characteristics for large datasets or high-dimensional feature spaces
  • Compatibility with specific model types beyond tree ensembles and transformers mentioned in documentation

Package facts

License MIT License (permissive)
Python support supports the current Python release (>=3.12)
Install friction medium — platform-specific wheel
Runtime dependencies 10 — numpy, scipy, scikit-learn, pandas, tqdm, packaging, slicer, numba, llvmlite, cloudpickle
Maintenance actively maintained — 78 days since the last release
Last repo commit
First released
Downloads 19,814,213/month — #1,054 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: shap-0.52.0-cp312-abi3-macosx_10_13_x86_64.whl; shap-0.52.0-cp312-abi3-macosx_11_0_arm64.whl; shap-0.52.0-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; shap-0.52.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; shap-0.52.0-cp312-abi3-musllinux_1_2_aarch64.whl; shap-0.52.0-cp312-abi3-musllinux_1_2_x86_64.whl; shap-0.52.0-cp312-abi3-win_amd64.whl; shap-0.52.0-cp314-cp314t-macosx_11_0_arm64.whl; shap-0.52.0-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; shap-0.52.0-cp314-cp314t-musllinux_1_2_aarch64.whl; shap-0.52.0-cp314-cp314t-musllinux_1_2_x86_64.whl

Development Status :: 5 - Production/StableIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: UnixProgramming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial Intelligence

Tags

machine learning model explainabilityfeature attribution shapley valuespredict explanation interpretabilitymodel output breakdownfeature importance analysistree ensemble explanationneural network interpretability
model-explainabilityinterpretabilityfeature-attribution

More Scientific/Engineering packages