Back to Classic ML Mind Map
中文·English
📊 Classic MLID: shap-lime

SHAP & LIME

可解释性 SHAP 与 LIME
🎯Core Definition
SHAP and LIME are the two most common model explainability methods. SHAP performs strictly additive feature attribution based on the game-theoretic Shapley value: ϕi=SN{i}S!(NS1)!N![v(S{i})v(S)]\phi_i = \sum_{S \subseteq N\setminus\{i\}} \frac{|S|!(|N|-|S|-1)!}{|N|!}[v(S\cup\{i\}) - v(S)], where v(S)v(S) is the expected prediction given feature subset SS and the weight S!(NS1)!N!\frac{|S|!(|N|-|S|-1)!}{|N|!} is the ordering share of feature ii among coalition permutations; Shapley values are the unique attribution satisfying efficiency, symmetry, dummy and additivity, decomposing the output exactly as iϕi=f(x)E[f]\sum_i \phi_i = f(x) - E[f]. TreeSHAP exploits the tree structure to compute exact values in O(TLD2)O(TLD^2) without sampling, while LIME fits a local interpretable surrogate mingL(f,g,πx)\min_g \mathcal{L}(f, g, \pi_x) — a sparse linear/decision model gg approximating ff in a πx\pi_x-weighted neighborhood around xx.
💡Use Cases
feature explanation for production risk/credit/recommendation models; interview questions like "SHAP vs LIME, how do you choose" or "how to attribute a black-box model"; global explanations via SHAP importance/dependence plots, local ones via force plots or LIME weights; in industry TreeSHAP is the default for tree ensembles.
Key Problems Solved
linear coefficients only explain additive-linear relationships, while SHAP decomposes any nonlinear model's output fairly across features — additivity guarantees iϕi=f(x)E[f]\sum_i \phi_i = f(x) - E[f], so attributions exactly sum to prediction minus baseline and stay comparable across models and samples; unlike LIME whose random sampling is non-reproducible, TreeSHAP is exact, fast and deterministic for trees.
🎯5 High-Frequency Exam Points
1
Write the Shapley formula ϕi=SN{i}S!(NS1)!N![v(S{i})v(S)]\phi_i = \sum_{S \subseteq N\setminus\{i\}} \frac{|S|!(|N|-|S|-1)!}{|N|!}[v(S\cup\{i\}) - v(S)], explain the weight S!(NS1)!N!\frac{|S|!(|N|-|S|-1)!}{|N|!}, and why it is the unique attribution satisfying efficiency/symmetry/dummy/additivity?
2
SHAP's additivity: why does iϕi=f(x)E[f]\sum_i \phi_i = f(x) - E[f]? How does it fundamentally differ from linear-model coefficients (LIME weights)?
3
Why can TreeSHAP compute exact values for trees? Decode O(TLD2)O(TLD^2) and explain why no sampling is needed.
4
Write LIME's surrogate objective mingL(f,g,πx)\min_g \mathcal{L}(f, g, \pi_x): what are gg, πx\pi_x, L\mathcal{L}? Why are LIME results unstable?
5
SHAP vs LIME: global vs local explanations, when to use which; applicability on tabular/image/text tasks?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "SHAP & LIME"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardData LeakageNext CardData Drift & PSI

🔗 More Classic ML Knowledge Cards

AdaBoost DerivationBagging & Random ForestBaum-Welch (HMM EM)GBDT Negative Gradient