Log inStart free
LESSON 4.62 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Counterfactual explanations

Watch a refused applicant find the smallest change that flips the model.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.62 · COUNTERFACTUAL BAYA · P 0.21 · REFUSED
01
Stage 1 of 6 · Model says no
A logistic regression trained on 24 past applicants refuses applicant A. Its p is 0.21, below 0.5.
Explain it simply

Each mark is a past applicant: a dot was approved, a square was refused. The blue line is where the model's chance p is one half. Applicant A sits on the refused side, with p of 0.21. A asks a fair question: what would change the answer?

A plane of income against debt with 24 past applicants and the model line. Applicant A has income 3.0 k$, debt 12.0 k$ and p 0.21.

applicants (dot approved, square refused)model line, counterfactualtarget, MADgap, cost
02468101205101520income x₁ (k$ a month) →debt x₂ (k$) →Awfeatureincome3.00.384debt12.0−0.403Ap = 0.5p(A) = 0.21 · refusedloan planeapplicant Az = 0.384·3.0 − 0.403·12.0 + 2.36 = 1.15 − 4.84 + 2.36 = −1.33 → p = σ(z) = 0.2102468101205101520income x₁ (k$ a month) →debt x₂ (k$) →Awfeatureincome3.00.384debt12.0−0.403Ap = 0.5p(A) = 0.21 · refusedloan planeapplicant Az = 0.384·3.0 − 0.403·12.0 + 2.36 = 1.15 − 4.84 + 2.36 = −1.33 → p = σ(z) = 0.21
Toy: 24 loan applicants · logistic regression · seeded
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
p=σ(w1x1+w2x2+b)\sy{p}{out}{p} = \sigma(\sy{w}{param}{w_1}\sy{x}{data}{x_1} + \sy{w}{param}{w_2}\sy{x}{data}{x_2} + \sy{w}{param}{b})
p=σ(1.15−4.84+2.36)=σ(−1.33)=0.21p = \sigma(1.15 -4.84 + 2.36) = \sigma(-1.33) = 0.21

The chance of approval comes from a weighted sum of income and debt.

Common mix-ups

MYTHEach person has one true counterfactual.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If only income may change, does A need a cheaper or a costlier change?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.