What kinds of machine learning models and data can SHAP explain?
Updated
SHAP (SHapley Additive exPlanations) is described in its documentation as "a game theoretic approach to explain the output of any machine learning model." That "any" is the key claim: SHAP is not tied to one algorithm family. It connects optimal credit allocation with local explanations using Shapley values from game theory and their extensions. In practice, the documentation organizes support along two axes — model type and data type — and the explainer you choose depends on where your model falls on those axes.
Models SHAP can explain
The documentation lists example categories that map directly to model families:
| Model family | Documentation example category |
|---|---|
| Tree-based models | Tabular examples → Tree-based models |
| Linear models | Tabular examples → Linear models |
| Neural networks | Tabular examples → Neural networks |
| Any model (model-agnostic) | Tabular examples → Model agnostic |
The "model agnostic" category matters most for the "any model" claim. When no specialized explainer fits, a model-agnostic approach can still produce explanations, at the cost of speed and, in some cases, precision compared with a tailored explainer.
Choosing an explainer by model
The documentation's API reference groups explainers separately, and the genomic examples specifically reference DeepExplainer. This reflects the general pattern: specialized explainers exist for particular model structures, and the right one depends on your model.
- Tree ensembles (e.g., gradient-boosted trees, random forests): use a tree-specific explainer.
- Neural networks: use
DeepExplainer, as shown in the genomics example. - Linear models: covered under the tabular linear-model examples.
- Anything else: fall back to a model-agnostic explainer.
The exact class names and signatures are in the API reference; check there before assuming a specific explainer name.
Data types SHAP covers
Beyond model architecture, the documentation organizes examples by data modality:
- Tabular — tree-based, linear, neural network, and model-agnostic examples.
- Text — sentiment analysis, translation, text generation, summarization, question answering, language modelling, and text entailment.
- Image — image classification and image captioning.
- Genomic — a
DeepExplainergenomics example.
So the answer to "what data can SHAP explain?" is broad: tabular rows, text sequences, image inputs, and genomic data all appear as documented examples. The constraint is not the data type itself but whether an appropriate explainer and model interface exist for your setup.
What to check before assuming support
Three practical conditions determine whether SHAP will work for your case:
- Your model exposes outputs SHAP can wrap. Model-agnostic explainers need a callable prediction function; specialized explainers need the model in a compatible form.
- An explainer matches your model structure. If a specialized explainer exists, it is usually the better choice; otherwise use the model-agnostic path.
- Your data fits a documented modality. Tabular, text, image, and genomic are covered; unusual modalities may still work through the model-agnostic route but are not shown as examples.
Where to start
The documentation's Topical overviews section includes "An introduction to explainable AI with Shapley values," which is the natural entry point for understanding the mechanism before picking an explainer. From there, the Examples section lets you find the category closest to your model and data, and the API reference gives the concrete explainer, plot, masker, and model utilities.
One caution the documentation itself raises: there is a topical overview titled "Be careful when interpreting predictive models in search of causal insights." SHAP explains a model's output, not causal relationships in the world — keep that distinction in mind when acting on any explanation.