Counterfactual Explanations
Intuition
"Your loan was rejected. If your income were 5 000 higher, it would have been approved." A counterfactual explains a decision by the smallest realistic change to the input that changes the outcome — and tells the person what they could do (recourse).
Precise explanation
For a classifier predict(X) -> labels, an instance with label , and per-feature step sizes
(0 = immutable, e.g. age or ethnicity):
- candidate changes: with integers ;
- cost: (number of unit steps, an L1 distance in step units);
- find the minimum-cost candidate whose label differs from , staying within optional bounds. Exhaustive search over candidates is fine for small problems and gives the true minimum; real systems use optimisation or heuristics. Ties: smallest cost, then lexicographically smallest step vector .
Worked example
predict = 1 if income + 2·savings ≥ 10; x = (4, 2) → 8 → class 0. Steps (1, 1): cost-1 options (5, 2) → 9 ✗, (4, 3) → 10 ✓ → counterfactual: savings + 1.
Common mistakes
- Changing immutable features.
- Returning any flipping point instead of the minimal one.
- Ignoring plausibility (bounds, realistic values).
Why this matters
Counterfactuals are human-friendly, actionable explanations and relate to legal discussions of a "right to explanation"; they also expose how close decisions are to the boundary.
References
- Interpretable Machine Learning (3rd edition) — Christoph Molnar (
S024)