Feature attribution har input feature ko ek single prediction ke liye numerical importance score assign karta hai. Global feature importance (jaise permutation importance) se alag, attribution instance-specific hota hai: wahi feature ek prediction ke liye critical ho sakta hai aur doosre ke liye irrelevant.
Challenge yeh hai: modern models (deep nets, ensembles) non-linear, interactive compositions hain. Kisi feature ka contribution doosre features ki values par depend karta hai. Hume ek principled tarika chahiye f(x) ko additive contributions mein decompose karne ka.
LIME model ko ek black box maanta hai aur ek locally faithful linear approximation banata hai.
Linear kyun? Humans linear models ko aasani se interpret karte hain: "feature xi prediction ko wi per unit badhata hai." Chahe f globally non-linear ho, x ke paas woh roughly linear ho sakta hai.
Yeh kaise kaam karta hai:
Perturbations generate karo: x ke paas naaye instances z∈Z randomly features toggle/perturb karke sample karo.
Proximity se weigh karo: Weight πx(z)=exp(−σ2d(x,z)2) assign karo taaki close neighbors zyada matter karein.
Local linear model fit karo: Solve karo
ξ(x)=argg∈GminL(f,g,πx)+Ω(g)
jahan G linear models ki class hai, L weighted squared loss hai, Ω(g) complexity ko penalize karta hai (jaise, L1 se kuch features select hote hain).
g ke coefficients LIME explanations hain: g(z)=w0+∑i=1dwizi.
SHAP cooperative game theory ke Shapley values par based hai. Socho features ek coalition mein players hain, aur "payout" model ki prediction hai.
Sawaal: Har player (feature) f(x) aur average prediction f(∅) ke beech ke difference mein kitna contribute karta hai?
Scratch se DERIVATION:
Setup: Hamare paas d features hain. Subset S ke liye, fS(xS) define karo expected prediction ke roop mein jab hum S ke features observe karte hain aur baaki ko marginalize karte hain:
fS(xS)=EX−S[f(xS,X−S)]
Marginalize kyun? Missing features ko zeros ke bajaye unki typical distribution se replace karte hain.
Marginal contribution: Jab hum feature i ko coalition S mein add karte hain, gain hai:
Δi(S)=fS∪{i}(xS∪{i})−fS(xS)
Saari orderings par average karo: Features ki d! orderings hoti hain. Har ordering mein, i kuch set S ke baad aata hai. Un orderings ki sankhya jahan i exactly S ke features ke baad aata hai: ∣S∣!⋅(d−∣S∣−1)!. Toh us configuration ki probability hai:
d!∣S∣!(d−∣S∣−1)!
Saare S∋i par Δi(S) ka weighted average Shapley value deta hai.
Result:ϕi feature i ko fair credit hai baseline f(∅) se f(x) tak prediction move karne ke liye.
Exact Shapley values ke liye 2d evaluations chahiye (saare subsets). High-dimensional data ke liye yeh intractable hai.
Solutions:
KernelSHAP (model-agnostic): Shapley values ko ek weighted linear model fit karke approximate karta hai (LIME jaisa, lekin specific Shapley weights ke saath). Samples →∞ hone par true Shapley par converge karta hai.
TreeSHAP (tree models ke liye): Tree structure exploit karta hai exact Shapley values polynomial time mein compute karne ke liye. Kaise: Tree traverse karo, feature splits track karo, aur paths par expectations compute karo.
DepSHAP (neural nets ke liye): Backpropagation + reference values use karke approximate karta hai.
LIME kyun use karein? Speed + simplicity. Tum ek one-off prediction ko reasonable samples ke saath seconds mein explain kar sakte ho. Prototyping aur user-facing apps ke liye badhiya jahan "roughly right" kaafi ho.
SHAP kyun use karein? Jab decisions high-stakes hoon (healthcare, finance) aur tumhe defensible, consistent explanations chahiye. SHAP ki additivity ka matlab hai tum ek prediction ko exactly decompose kar sakte ho. TreeSHAP tree models ke liye fast bhi hai.
Recall Ek 12-saal ke bachche ko explain karo
Socho tumhara teacher tumhe ek group project par grade deta hai. Tum jaanna chahte ho: "Maine kitna contribute kiya vs mere teammates ne?"
LIME aisa hai jaise paas ke kuch classmates se poochho: "Agar main group mein nahi hota, toh kya grade kam hota?" Phir unke jawaabon ka average lo. Yeh quick hai, lekin agar alag logon se poochho, toh alag jawab mil sakte hain.
SHAP aisa hai jaise teacher carefully calculate kare: "Agar main imagine karun saare possible groups with aur without tumhare, aur average karun ki grade kitna badlta hai jab tum add hote ho, wahi tumhara exact contribution hai." Yeh fair hai, sab isse agree karte hain, lekin compute karne mein zyada time lagta hai.
Dono tumhe samajhne mein help karte hain kyun grade (prediction) woh hai jo hai, ek feature (person) ek baar mein.
3.5.04-Tree-ensembleinterpretation – TreeSHAP fast exact computation ke liye tree structure leverage karta hai.
#flashcards/ai-ml
Feature attribution kya hai? :: Har input feature ko ek single prediction ke liye numerical importance score assign karna, yeh dikhate hue ki har feature ne us specific output mein kitna contribute kiya.
LIME "local" kyun hai?
LIME instance x ke aas-paas ek chote neighborhood mein ek simple interpretable model (linear) fit karta hai, proximity πx(z)=exp(−d(x,z)2/σ2) se weighted.
LIME objective function derive karo :: Weighted squared loss se shuru karo L=∑zπx(z)[f(z)−g(z)]2 (x ke paas f ke closeness ke liye), complexity penalty Ω(g)=λ∥w∥1 (sparsity) add karo, unka sum minimize karo locally faithful sparse linear g paane ke liye.
Shapley values kya hain?
Unique fair attribution jo efficiency (∑ϕi=f(x)−f(∅)), symmetry, dummy, aur linearity satisfy karta hai. Feature i ke liye: ϕi=∑Sd!∣S∣!(d−∣S∣−1)![fS∪{i}−fS], saari coalitions par averaged marginal contribution.
SHAP values prediction mein kyun sum hote hain?
Shapley values ke efficiency axiom se: f(x)=ϕ0+∑i=1dϕi(x), jahan ϕ0 base rate hai. Yeh exact hai, approximate nahi.
TreeSHAP polynomial time kaise achieve karta hai?
Tree structure exploit karta hai: har split ke liye, training data ka fraction compute karo jo har direction jaata hai, use alternative branch ki expectation weight karne ke liye use karo. Saare 2d subsets explicitly enumerate karne ki zaroorat nahi.
LIME high variance mistake aur fix
Bahut kam perturbations use karna (jaise 10) linear fit ko unstable banata hai; explanations ek run se doosre mein wildly vary karte hain. Fix: 1,000–10,000 samples use karo aur multiple runs mein stability check karo.
Key difference: LIME vs SHAP guarantees :: LIME ek approximation hai jisme fidelity ya additivity ki koi theoretical guarantee nahi. SHAP mein axiom-based guarantees hain: efficiency, symmetry, dummy player, jo ise theoretically sound aur consistent banate hain.
SHAP pe LIME kab use karein?
Jab prototyping ya low-stakes user-facing explanations ke liye speed aur simplicity chahiye, aur approximate local fidelity kaafi ho. LIME flexible sampling ke saath kisi bhi model type ko explain kar sakta hai.
Shapley derivation mein fS(xS) kya hai?
Expected prediction jab subset S ke features xS par observe kiye jaate hain aur S mein nahi hone wale features marginalize kiye jaate hain: fS(xS)=EX−S[f(xS,X−S)]. Yeh marginal contributions compute karne ke liye baseline define karta hai.