L1 distance (∥x′−x∥1): Encourages changing few features. L1 gives sparse solutions (many components stay at zero change). Why not L2? L2=∑(xi′−xi)2 spreads change across many features; L1=∑∣xi′−xi∣ concentrates it.
Hinge loss on prediction: For binary classifier outputing probability p=f(x′):
hinge(p)=max(0,0.5−p)
This is zero when p>0.5 (desired class), positive otherwise. Why hinge? Differentiable, pushes p past decision boundary.
Manifold distance: Penalizes unrealistic combinations. Could use:
Distance to nearest training point: minxi∈train∥x′−xi∥
Trade-offs: Proximity vs. plausibility (closest counterfactual might be unrealistic). Sparsity vs. validity (changing1 feature might not suffice).
Recall Explain to a 12-Year-Old
Imagine you applied to a club and got rejected. You ask, "Why?" They say, "Because reasons." Not helpful!
Now imagine they say: "If you had2 more friends already in the club, you'd be accepted." That's a counterfactual—it tells you exactly what to change to get in.
Counterfactual explanations for AI are the same: the computer says "You were rejected for a loan. But if your income was $5k higher, you'd be approved." It's not explaining its whole decision process—it's giving you a specific action you can take.
Why is this better than "Your income was important"? Because "important" doesn't tell you how much to change it. The counterfactual gives you a concrete goal.
Model Debugging: Out-of-distribution counterfactuals reveal model flaws and biases
#flashcards/ai-ml
What are the three key properties a counterfactual explanation must satisfy? :: (1) Validity: f(x′)=y′ (different prediction), (2) Proximity: x′ is close to x (minimal change), (3) Plausibility: x′ is realistic/actionable
Why do we use L1 norm instead of L2 norm for counterfactual proximity in tabular data?
L1=∑∣xi′−xi∣ encourages sparse changes (few features modified), while L2=∑(xi′−xi)2 spreads small changes across many features. For interpretability, we want to change as few features as possible.
Write the optimization objective for generating a counterfactual x′ from x :: $$\min_{\mathbf{x}'} |\mathbf{x}' - \mathbf{x}|1 + \lambda \cdot \text{hinge}(f(\mathbf{x}')) + \gamma \cdot d{\text{manifold}}(\mathbf{x}') \text{ where the three terms balance proximity, prediction validity, and realism.}
What is the "actionability" problem in counterfactual explanations?
Some features are immutable (age, race, past events) or difficult to change. A counterfactual suggesting "change your age from 25 to 45" is mathematically valid but useless to the user. Solution: mark immutable features with infinite cost or hard constraints.
How does DiCE (Diverse Counterfactual Explanations) differ from single-counterfactual methods? :: DiCE generates multiple diverse counterfactuals by adding a diversity term -\gamma \sum_{i<j} |\mathbf{x}_i' - \mathbf{x}_j'| that penalizes similarity between counterfactuals. This gives users options: "Either increase income OR improve credit score."
For a linear classifier f(\mathbf{x}) = \text{sign}(\mathbf{w}^\top \mathbf{x} + b), what is the closest point on the decision boundary to \mathbf{x}? :::xboundary=x−∥w∥2w⊤x+bw This is derived by minimizing ∥x′−x∥2 subject to w⊤x′+b=0 using Lagrange multipliers.
What is the plausibility constraint in counterfactual generation and how is it enforced?
Plausibility ensures x′ lies in the data manifold (realistic). Enforced by: (1) distance to nearest training point, (2) VAE reconstruction error, (3) feature validity constraints (e.g., age ≥0), or (4) generating x′=G(z) through a generative model.
Why are counterfactuals more actionable than SHAP or LIME explanations?
SHAP/LIME explain "which features contributed to the prediction" (attribution), while counterfactuals specify "change feature X from value A to value B for outcome Y" (prescription). Counterfactuals directly answer "what should I do?" making them more actionable for end users.
Counterfactual explanations ka matlab hai: "Agar aapne input mein yeh chota sa change kiya hota, toh model ka decision ulta ho jata." Jaise agar loan rejecthua, toh system bolega: "Agar aapki salary45k ke bajaye 52k hoti, toh approve ho jata." Yeh explanation sirf bata nahi ki kya importantha—yeh directly action plan deta hai ki kya karna hai.
Teen important chezein honi chahiye har counterfactual mein: (1) Close* – original input se bahut zyada change nahi, (2) Correct – nayi input pe prediction sach mein flip honi chahiye, (3) Credible – realistic change hona chahiye, impossible nahi (jaise "age 25 se 45 karo" bilkul bekar explanation hai, kyunki age toh change nahi ho sakti). Hamara optimization formula L1 distance use karta hai taki kam se kam features change hon (sparse solution), aur sath mein ek penalty term hota hai jo check karta hai ki naya input training data jaisa realistic hai ya nahi.
Counterfactuals kafi powerful hain kyunki yeh human thinking ke pas hain—hum naturally sochte hain "agar maine yeh kiya hota toh..." Aur users ke liye actionable hote hain: LIME ya SHAP sirf batate hain "income importantha," lekin counterfactual kehta hai "income 7k aur badha do." Isse users ko clear direction milta hai. DiCE method multiple diverse counterfactuals deta hai—matlab options milte hain: "Ya toh income badhao YA credit score improve karo." Yeh flexibility real-world mein bahut kaam ati hai.