Where to Find SHAP Examples and API Reference in the Documentation
Updated
The SHAP documentation at shap.readthedocs.io organizes examples by data type and puts the full API reference in a dedicated Reference section. If you want to see working code for a specific task, start with the Examples section and pick the category that matches your data (tabular, text, image, or genomic). If you need function signatures, class definitions, and parameter details, go to Reference → API reference. The site also provides topical overviews for conceptual background, API examples for migration and usage patterns, and benchmarks for performance comparisons.
Documentation structure at a glance
The site's navigation follows this layout:
- Introduction – conceptual material
- Topical overviews – explainable AI with Shapley values, causal interpretation cautions, fairness measures
- Examples – organized by data modality
- Reference – API reference and API examples
- Benchmarks – image, tabular, text, and others
- Development – release notes and contributing guide
Finding examples for your task
The Examples section is split by data type, so you can go directly to the relevant page:
| Data type | What you'll find |
|---|---|
| Tabular | Tree-based models, linear models, neural networks, model-agnostic methods |
| Text | Sentiment analysis, translation, text generation, summarization, question answering, language modelling, text entailment |
| Image | Image classification, image captioning |
| Genomic | DeepExplainer genomics example |
If you're unsure which explainer fits your model, the tabular examples cover the most common cases (tree-based, linear, neural, model-agnostic) and are a reasonable starting point even for non-tabular work, since the explainer API is consistent across modalities.
Finding the API reference
The Reference section contains two parts:
- API reference – organized into Explanation, explainers, plots, maskers, models, utils, and datasets
- API examples – practical usage for explainers, maskers, models, and plots, plus a guide on migrating to the new "Explanation" API
Use the API reference when you need exact parameter names, return types, or available methods. Use the API examples when you want to see how those objects are used together in a workflow.
Conceptual background before you code
The Topical overviews section covers three topics worth reading before applying SHAP:
- An introduction to explainable AI with Shapley values
- A caution about interpreting predictive models for causal insights
- Explaining quantitative measures of fairness
These give the theoretical grounding for why SHAP values behave the way they do and where interpretation can go wrong.
Installation
SHAP installs from either PyPI or conda-forge:
pip install shap
or
conda install -c conda-forge shap
When to use which section
- New to SHAP → Topical overviews, then a tabular example
- Have a specific model type → the matching Examples subpage
- Need exact function signatures → Reference → API reference
- Migrating existing code → Reference → API examples → migrating to the new "Explanation" API
- Comparing performance → Benchmarks
- Checking version changes → Development → Release notes