← Back to Classic ML Mind Map
⚡Flashcard Drill➔
📊 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=∑S⊆N∖{i}∣S∣!(∣N∣−∣S∣−1)!∣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∣!(∣N∣−∣S∣−1)!∣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 min⁡gL(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.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of SHAP & LIME.
Use Cases
In production engineering, what are the primary use cases for SHAP & LIME and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Write the Shapley formula ϕi=∑S⊆N∖{i}∣S∣!(∣N∣−∣S∣−1)!∣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∣!(∣N∣−∣S∣−1)!∣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 min⁡gL(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
🎯
Verify Mastery: Practice Exam Questions for "SHAP & LIME"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
← Previous CardData LeakageNext Card →Data Drift & PSI

🔗 More Classic ML Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/ML/card/shap-lime