Interpretability: SHAP, LIME & Their Limits
Explaining predictions, and how explanations can mislead.
Feature attributions appear in medical papers, credit decisions and every debugging session. They rest on an elegant theorem from cooperative game theory, and on choices the theorem does not make for you. This lesson derives the Shapley value and its uniqueness, shows exactly what SHAP, LIME, partial dependence and integrated gradients compute, and then collects the results that show where explanations fail: equally accurate models with different explanations, explainers that can be fooled, saliency maps that ignore the model, and a theorem that complete, linear attributions can fail to beat random guessing.
What you’ll learn
- Distinguish what interpretability can mean, and how explanations can be evaluated.
- Prove that the Shapley value is the unique attribution satisfying efficiency, symmetry, null player and additivity, and state the weighted regression that KernelSHAP solves.
- Compare interventional and conditional value functions, LIME, partial dependence, ICE, accumulated local effects and integrated gradients.
- Explain the Rashomon effect, adversarial fooling of perturbation-based explainers, saliency sanity checks and the impossibility theorems for feature attribution.
What would count as an explanation?
"Interpretable" means different things to different people. Lipton (2018) separated transparency, properties of the model itself (a person can simulate it, each part has a meaning, the training algorithm is understood), from post-hoc explanations, which extract information from a trained model without showing exactly how it works: text, visualizations, local explanations, examples. Doshi-Velez & Kim (2017) argued that interpretability needs rigorous evaluation, and proposed three kinds of evaluation.
| Evaluation | Who and what | Trade-off |
|---|---|---|
| Application-grounded | domain experts doing the real task, such as doctors diagnosing patients with the system's help | most convincing; expensive and specific |
| Human-grounded | lay participants on simplified tasks, such as predicting the model's output from an explanation | cheaper; tests general properties, not the real use |
| Functionally-grounded | no humans: a formal proxy for interpretability, such as sparsity, ideally one already validated with humans | cheapest; only as good as the proxy |
This lesson concerns local feature attribution: given a model , an input and usually a reference distribution or baseline, return a number per feature saying how much feature contributed to . The global tools of Feature Importance & Its Pitfalls (permutation importance, model reliance) and the interpretable-by-design models of Optimal & Interpretable Trees answer different questions.
The Shapley value
For nonempty , the unanimity game pays only when all of is present. The unanimity games form a basis of all games: every is a combination whose coefficients, the Harsanyi dividends, come from Möbius inversion:
Fix the game for a real . Players outside are null, so they get 0. Players inside are symmetric, so they share equally. Efficiency says the shares add up to :
Additivity then determines on every game: each dividend is split equally among its members. Any two maps with the four properties agree on a basis, hence everywhere; and the Shapley formula has all four properties (each is easy to check from the random-order form), so it is that map.
Two features. Knowing neither gives the baseline, ; knowing only feature 1 adds 10, only feature 2 adds 20, and both together add 50. What is feature 1's Shapley value?
Show the answer
20
Average its marginal contributions over the two orders: first, ; second, ; so and likewise , summing to 50. In dividend terms, , and the interaction is split equally.
To explain a prediction, make the features players and choose a value function , "what the model predicts when only the features in are known", minus its value for . Efficiency then splits among the features: this is SHAP (Lundberg & Lee, 2017). The axioms say nothing about which value function to use, and that choice changes the answers.
Which game? Value functions and KernelSHAP
Three value functions are in common use. Interventional (or marginal): , filling in unknown features from their marginal distribution. Conditional: . Baseline: for one reference input . With independent features the first two coincide. With dependent ones they can disagree completely.
Let be standard normal with correlation , and let the model read only the first feature, . Under the conditional value function, knowing is informative about :
Average the marginal contributions over the two orders:
At with the conditional attributions are : 40% of the credit goes to a feature the model never touches. The interventional value function gives and hence .
Which is right depends on the question. Interventional values describe the function: a feature the model ignores gets nothing, which is what you want when debugging a model, and Janzing, Minorics & Blöbaum (2020) argue from Pearl's distinction between observing and intervening that dropping a feature should be modeled as an intervention on the model's input. Conditional values describe the information the features carry about the prediction. Sundararajan & Najmi (2020) showed that the many ways of operationalizing the Shapley value give very different attributions, some of them nonzero for features the model never references, so the celebrated uniqueness result does not by itself justify any one of them; they proposed Baseline Shapley (BShap), backed by its own uniqueness result. The interventional choice has a price: it evaluates on combinations such as a high income paired with a student's age that may never occur in data, where the model is unconstrained, a weakness exploited below. Kumar, Venkatasubramanian, Scheidegger & Friedler (2020) argue more broadly that the remedies for the mathematical problems of Shapley-based importance bring in further complexity, such as the need for causal reasoning.
Other lenses: LIME, effect plots and gradients
LIME (Ribeiro, Singh & Guestrin, 2016) explains near by an interpretable surrogate:
where is a class of simple models (typically sparse linear ones), weights perturbed samples by their proximity to (an exponential kernel of the distance, with a width parameter), and penalizes complexity. KernelSHAP is this same template with the Shapley kernel, squared loss and no penalty; LIME's heuristic choices do not recover Shapley values and can violate efficiency. In practice LIME's explanations depend on the kernel width and on the random perturbations, so two runs can disagree.
Effect plots describe how the prediction varies with one feature. Partial dependence (Friedman, 2001) averages with feature set to in every example, which evaluates the model off the data whenever features are dependent. Individual conditional expectation curves (Goldstein, Kapelner, Bleich & Pitkin, 2015) show the per-example curves that the average hides. Accumulated local effects (Apley & Zhu, 2020) avoid extrapolation by averaging derivatives over the conditional distribution and integrating:
then centering. For an additive model both partial dependence and ALE recover up to a constant; they part ways when features are dependent and the model interacts.
Integrated gradients (Sundararajan, Taly & Yan, 2017), for differentiable models, accumulate gradients along the straight path from a baseline to :
They satisfy sensitivity (a feature that alone changes the output gets credit, which plain gradients violate at saturation) and implementation invariance (functionally identical networks get identical attributions). Path methods are the only attributions with implementation invariance, a dummy property, linearity and completeness; integrated gradients are the symmetric one among them, the Aumann–Shapley cost-sharing rule of economics.
| Method | Reference point | Completeness | Main failure |
|---|---|---|---|
| SHAP, interventional | marginal distribution of absent features | yes | evaluates the model off the data manifold |
| SHAP, conditional | conditional distribution | yes | credits features the model never reads; hard to estimate |
| LIME | perturbations weighted by proximity | no | unstable; depends on kernel width |
| Partial dependence / ICE | the data, feature overwritten | not applicable (global or per-example curve) | extrapolates under dependence |
| ALE | local conditional derivatives | not applicable | needs enough data per interval; describes effects, not causes |
| Integrated gradients | a baseline input | yes | depends on the baseline; differentiable models only |
How explanations mislead
Many good models, many stories. Breiman (2001) called it the Rashomon effect: a dataset typically admits many models with nearly the same accuracy that differ in which features they use and how, so an explanation of one of them is not an explanation of the data.
Explainers can be fooled. Perturbation-based explainers query the model on synthetic points that differ visibly from real data. Slack, Hilgard, Jia, Singh & Lakkaraju (2020) exploited this with a "scaffolding": a classifier that detects whether an input looks like real data, applies a biased rule (for example, one using race) on real inputs and an innocuous rule on the perturbations. Its predictions on real data stay biased, yet LIME and KernelSHAP report the innocuous feature, as their experiments on datasets including COMPAS showed.
Saliency maps can ignore the model. Adebayo et al. (2018) proposed two sanity checks for saliency methods on images: randomize the model's weights, or retrain it on randomized labels, and see whether the explanation changes. Plain gradients and GradCAM passed; Guided Backpropagation and Guided GradCAM were largely invariant to the parameters of the higher layers, behaving more like edge detectors than explanations of the model.
Attributions can be no better than chance. Bilodeau, Jaques, Koh & Kim (2024) proved that for model classes rich enough to contain piecewise-linear functions, such as ReLU networks, any attribution method that is complete (attributions sum to minus the baseline average) and linear (an additive model's attributions come from its additive parts), a class that includes SHAP and integrated gradients, can fail to beat random guessing for end tasks such as algorithmic recourse and spotting spurious features. There are uncountably many pairs of models with identical attributions but arbitrarily different local behavior. A positive attribution does not imply that increasing the feature increases the output, and a zero attribution does not imply insensitivity. Simple direct methods, such as evaluating the model repeatedly near , can do better once the end task is stated.
Key takeaways
- Interpretability means transparency or post-hoc explanation, and explanations should be evaluated against an end task: application-, human- or functionally-grounded.
- The Shapley value is the unique attribution with efficiency, symmetry, null player and additivity (proof: unanimity games and Harsanyi dividends); KernelSHAP computes it as weighted least squares with the Shapley kernel.
- The value function is a modeling choice: interventional values follow the function but query it off the data; conditional values can credit features the model never reads.
- LIME fits a local surrogate with heuristic weights; partial dependence extrapolates under dependence, ALE does not; integrated gradients are the Aumann–Shapley path attribution, complete and implementation-invariant.
- Explanations mislead: Rashomon sets of equally accurate models, scaffolds that fool LIME and SHAP, saliency maps that ignore the weights, and complete, linear attributions that can be no better than random guessing for recourse.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Which Shapley axiom guarantees that the attributions of a prediction add up to ?
- Symmetry
- Efficiency
- Null player
- Additivity
Show the answer
B. Efficiency
Efficiency says , and with measured relative to the baseline, . In the SHAP paper this is called local accuracy.
A model uses only feature 1, but conditional SHAP assigns substantial credit to feature 2. What is going on?
- A bug: Shapley values always give zero to unused features
- Feature 2 is correlated with feature 1, and the conditional value function credits the information it carries about the prediction
- The model secretly uses feature 2
- KernelSHAP sampling noise
Show the answer
B. Feature 2 is correlated with feature 1, and the conditional value function credits the information it carries about the prediction
Under , knowing changes the expected prediction through its correlation with , so feature 2 is not a null player of this game even though ignores it. Interventional values would give it zero.
How does KernelSHAP relate to LIME?
- They are unrelated: one is game-theoretic, the other a local surrogate
- KernelSHAP is LIME with an penalty
- KernelSHAP is the LIME template with the Shapley kernel, squared loss and no regularization, whose solution is exactly the Shapley values
- LIME is a special case of integrated gradients
Show the answer
C. KernelSHAP is the LIME template with the Shapley kernel, squared loss and no regularization, whose solution is exactly the Shapley values
Lundberg & Lee showed that the weighted linear regression of LIME recovers Shapley values for exactly one choice of kernel, loss and penalty. LIME's default heuristic choices do not, which is why its attributions need not sum to the prediction.
A complete and linear attribution method assigns a large positive value to feature at input for a ReLU network. What can you conclude about increasing slightly?
- The output will increase
- The output will increase, unless the feature is correlated with another
- The output will not decrease
- Nothing in general: models with the same attributions can respond in opposite directions
Show the answer
D. Nothing in general: models with the same attributions can respond in opposite directions
Bilodeau et al. (2024) show that for rich model classes such attributions are compatible with arbitrarily different local behavior; completeness ties them to the gap between and the baseline, which can be dominated by behavior far from . To learn about small changes of , evaluate the model at nearby points or look at the gradient.
Further reading
- L. S. Shapley, "A value for n-person games," in Contributions to the Theory of Games II, Annals of Mathematics Studies 28, 307–317 (Princeton University Press, 1953).
- S. M. Lundberg & S.-I. Lee, "A unified approach to interpreting model predictions," Advances in Neural Information Processing Systems 30 (2017).
- M. T. Ribeiro, S. Singh & C. Guestrin, "'Why should I trust you?': Explaining the predictions of any classifier," Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 1135–1144 (2016).
- B. Bilodeau, N. Jaques, P. W. Koh & B. Kim, "Impossibility theorems for feature attribution," Proceedings of the National Academy of Sciences 121(2), e2304406120 (2024).
- C. Rudin, "Stop explaining black box machine learning models for high stakes decisions and use interpretable models instead," Nature Machine Intelligence 1(5), 206–215 (2019).