Shapley Values
Intuition
Features are players in a cooperative game whose payout is the prediction. A fair split gives each player their average marginal contribution over every order in which players could join.
Precise explanation
Value of a coalition (baseline/interventional version): evaluate the model on an input that takes for and the baseline otherwise: . Shapley value of feature among features:
Properties (Lundberg & Lee 2017; Molnar ch. "Shapley values"):
- Efficiency: .
- Symmetry: interchangeable features get equal values.
- Dummy: a feature that never changes gets 0. For a linear model, (XA-01). Exact computation needs model calls — feasible only for small d; SHAP approximates it for larger models.
Worked example
f(x) = x₀·x₁, x = (1, 1), baseline (0, 0): v(∅) = 0, v({0}) = 0, v({1}) = 0, v({0,1}) = 1 → φ₀ = ½(0 − 0) + ½(1 − 0) = 0.5, φ₁ = 0.5. The interaction is split equally.
Common mistakes
- Wrong weights (use ).
- Forgetting the empty coalition.
- Different baselines give different (both valid) explanations — report which you used.
Why this matters
SHAP is one of the most widely used explanation tools; implementing the exact formula shows what the approximations approximate.
References
- A Unified Approach to Interpreting Model Predictions — Scott Lundberg, Su-In Lee (
S026) - Interpretable Machine Learning (3rd edition) — Christoph Molnar (
S024)