6.3.10 · D5Interpretability & Explainability

Question bank — Counterfactual explanations

1,464 words7 min readBack to topic

Before we start, three tiny reminders so no symbol appears "cold":

Recall What the core symbols mean
  • ::: the original input (a person's features, or an image's pixels).
  • ::: the trained model; is its prediction (e.g. = denied, = approved).
  • ::: the counterfactual — a nearby input we search for so that .
  • ::: the ("taxicab") distance — sum of the absolute changes across features; small = few/small edits.

True or false — justify

A counterfactual explanation and a feature-importance score answer the same question.
False. Importance tells you which features mattered on average; a counterfactual tells you the specific minimal edit to that flips this one prediction. Contrastive, not aggregate.
The closest counterfactual is always the most useful one.
False. "Closest" only optimises proximity. If the closest edit changes an immutable feature (age, birthplace), it is mathematically valid but useless — usefulness also needs actionability and plausibility.
Every input has exactly one counterfactual.
False. There are usually many valid on the far side of the boundary; that is precisely why DiCE searches for a diverse set rather than a single point.
A valid counterfactual must lie on the decision boundary.
False. It must lie past the boundary (strictly in the target class region). The boundary point is the cheapest candidate for a linear model, but validity requires , which holds strictly beyond it.
Using instead of only changes the numbers, not the character of the answer.
False. tends to concentrate change into few features (sparse edits); spreads a little change across many. The resulting explanations look qualitatively different — a story about one feature vs. a diffuse nudge.
A counterfactual and an adversarial example are computed by unrelated procedures.
False. Both minimise input change subject to flipping . The math is nearly identical; the difference is intent and constraints — see Adversarial Examples. Counterfactuals add plausibility/actionability so the flip is meaningful, not a hidden pixel attack.
If a counterfactual flips the prediction, the user genuinely can act on it.
False. Flipping is a property of the model; acting is a property of the world. Recourse is the extra requirement that the suggested change be feasible for this person to perform.
The plausibility term is optional decoration.
False. Without it, gradient descent happily finds off-manifold points (negative income, impossible pixel noise) — exactly the adversarial regime. Plausibility keeps inside realistic data.

Spot the error

"To get approved, change your age from 25 to 45 — it flips the model."
The error is ignoring immutability. Age cannot be edited, so this "explanation" gives no recourse. Fix: set the change cost so the optimiser never touches it.
"We used for tabular loan features because it gave the smallest total change."
Smallest total change under typically nudges every feature a little, producing an unreadable explanation. Tabular counterfactuals should prefer for sparse, human-digestible edits.
"The hinge term is positive once we cross the boundary, so it keeps pushing."
Reversed. It is zero once and positive before — it stops pushing exactly when the target class is reached, which is what we want.
"Our counterfactual raises education to 'PhD', so it's actionable — just go get one."
Actionable in principle, but the causal graph matters: obtaining a PhD also changes years-of-experience, age, and income. A Causal Inference-aware method (FACE) propagates these downstream effects instead of editing one node in isolation.
"We proved the linear boundary formula, so the same closed form works for our neural net."
The closed form assumes a single flat boundary. Neural boundaries curve, so we must walk toward them with gradient descent — no closed form.
"The optimiser returned income = $51.4k, so we tell the user 'earn $51,400 exactly'."
Continuous optima need rounding to actionable granularity ("about $52k"). For categorical one-hot features, the analogous error is reporting fractional categories instead of rounding to a valid level.
"Diversity term is ; the minus is a typo, it should be plus."
The minus is intentional. We minimise the loss, so a minus rewards large pairwise distances — pushing the counterfactuals apart to be genuinely different options.

Why questions

Why does give sparser edits than ?
's cost grows linearly, so shrinking one feature's change to exactly zero is always worthwhile; penalises large deviations quadratically, so it "prefers" many small nonzero changes over one big one — never quite hitting zero.
Why use hinge loss rather than "just require " as a hard constraint?
A hard equality on a discrete label gives no gradient to follow. Hinge on the probability is smooth and non-zero until we cross , providing a direction for gradient descent to push.
Why does a counterfactual "reveal what the model looks at" in the image example?
The minimal pixels it must change to flip the label are the pixels the model most relies on. If tiny ear-tweaks flip cat→dog, the model leaned on ear shape — a debugging signal, see Model Debugging.
Why start the optimisation at rather than a random point?
We want the nearest counterfactual. Starting at biases gradient descent to stay close and cross the boundary at the cheapest spot instead of wandering to a far-off valid region.
Why can two "equally valid" counterfactuals be wildly unequal in worth?
Validity only checks the flipped label. Two edits with the same cost can differ in actionability (one changes a mutable feature, one an immutable one) and in causal side-effects — worth lives in those extra dimensions.
Why do immutable features get cost rather than just a "large" weight?
A large-but-finite weight still lets the optimiser touch the feature if flipping is desperate enough. Infinity makes any change infinitely costly, guaranteeing it never moves.

Edge cases

What is the counterfactual when is already in the target class?
There is none to find — the request is degenerate. A well-built system returns "no change needed," since the minimal edit is the zero edit.
What if every actionable feature is fixed and only immutable ones could flip the label?
Then no valid recourse exists. The honest output is "no achievable counterfactual," which itself is important information about model unfairness — see Recourse.
What happens at a point sitting exactly on the decision boundary ()?
It belongs to neither class cleanly; an infinitesimal push either way flips it. The hinge is exactly zero at , so proximity dominates and the counterfactual is essentially itself.
What if the optimiser converges but still equals the original class?
The weight on the prediction term was too small relative to proximity, so the search stopped before crossing. Increase (or run more steps) — validity was never achieved.
What about a feature that can only increase (e.g. total years of education)?
A plain clip to isn't enough; we must project onto after each step. This is a directional constraint that a causal/FACE method encodes explicitly.
What if two features are causally linked (income depends on job tenure)?
Editing one should move the other. A method blind to the Causal Inference structure produces an impossible combo (tenure up, income magically flat); a DAG-constrained method updates the descendant automatically.
What is the limiting behaviour as with proximity fixed?
The prediction term dominates entirely; the search drives far past regardless of distance, often landing on an implausible, adversarial-looking point — the exact failure the plausibility term exists to prevent.