nachosanbenito.com Interactive explainer

Quantum project 3, credit risk

Turning a loan application into points.

Nine answers, nine boxes of points, one sum. Built on 1,000 real German loans, then graded on 300 it never saw.

Loan applicationa real applicant, never seen in training
  1. Checking accountOverdrawn, under 0 DM
    +36
  2. Loan length12 months
    +65
  3. Credit historyExisting credits paid on time
    +53
  4. PurposeRadio / TV
    +70
  5. In current job7 years or more
    +66
  6. Other instalment plansNone
    +60
  7. Savings500 to 1,000 DM
    +72
  8. Amount1,680 DM
    +63
  9. Instalment, share of incomeBand 3 of 4
    +66
Score551
Cutoff 539ApprovedOutcome: repaid

The whole build in 69 seconds.

Narrated, with sound: the bins, the weights, the regression, the points and the tests that try to break it.

Where the 36 comes from.

Take the first box, the overdrawn checking account. Four steps turn it into 36 points, and the same four steps make every other box.

Cut every answer into a few bins

Checking account has four bins. Among the 700 training loans, the share who defaulted climbs from 12% with no account to 51% when overdrawn.

Numbers like loan length are binned so risk moves one way only. A lender won't sign a card where risk rises, falls and rises again.

Weigh each bin: Weight of Evidence

WOE = ln( % of repayers in bin ÷ % of defaulters in bin )

Overdrawn holds 19.8% of the repayers but 47.6% of the defaulters: ln(0.198 ÷ 0.476) = −0.88. Above zero means safer than average, below means riskier.

Let a regression set the weights

ln(odds of default) = α + Σ βᵢ · WOEᵢ

Logistic regression on the WOE values, α = −0.866. Every β must be negative, so safer evidence always pushes the score up; checking account gets β = −0.833 (p = 3×10⁻¹¹).

Telephone entered at p = 0.02 but survived only 36% of 25 rebuilds, so it is out. Nine characteristics stay.

Turn weights into points

points = −(β · WOE + α ÷ n) × factor + offset ÷ n

factor = 20 ÷ ln 2 = 28.85 and offset = 487.12, so 600 points mean 50:1 odds of repaying and every 20 points double them. With n = 9:

−(0.731 − 0.096) × 28.85 + 54.12 = 35.8 → 36

Add the nine boxes

Our applicant: 36 for the overdrawn account, then 65, 53, 70, 66, 60, 72, 63 and 66. Total 551, above the cutoff of 539.

The worst possible answers still add up to 348 and the best to 655, so every score lives between those two.

Score 300 applications it never saw

The holdout: 210 people who repaid (above the line) and 90 who defaulted (below). No step of the build touched them.

The two crowds overlap a lot. A scorecard ranks people, it can't sort them perfectly.

Draw the line by cost, not accuracy

cost = 5 × defaulters approved + 1 × repayers turned away

The cheapest line on the training book is 539. On the holdout it approves 99 people (33%) and 8 of them default: 0.530 per applicant, against 1.50 approving everyone and 0.70 approving no one.

Tuning the line on the holdout itself would show 0.503, a 5% flattery. The line is chosen first and paid for after.

Measure the ranking: Gini

Pick one repayer and one defaulter at random: 78.0% of the time the repayer scores higher. That is the AUC.

Gini = 2 × AUC − 1 = 2 × 0.780 − 1 = 0.560

On its own 700 training rows it read 0.659: the gap is overfit. Rebuilt 25 times, 90% of results fall between 0.41 and 0.67, so 0.560 means "somewhere in there".

Where it breaks.

Same score, different ending

Another holdout applicant scored 552 and defaulted. At 551 the card gives odds of about 9 to 1, so roughly one in ten people with this score still won't pay.

A score is odds, not a verdict.

A black box doesn't win here

AUC on the same 300 unseen applications.

Scorecard (WOE + logistic)0.780 Gradient boosting0.767 Logistic on raw answers0.746

Bars start at AUC 0.5, a coin flip. On 700 rows binning regularises hard; on a million-row book this order would likely flip.

Fairness, audited anyway

Sex and nationality never enter the model. Other answers can still stand in for them, so the finished card is checked.

0.89

Approval rate of women over men (30.4% vs 34.1%), above the 0.8 four-fifths line.

What it doesn't do

  • 1,000 rows is not a bank book. Every number carries an interval: Gini ±0.083 across rebuilds.
  • No reject inference. Only approved loans have outcomes, so the people a bank turned away are missing.
  • No out-of-time test. The holdout is a random 30%, not a later year.
  • The 5:1 cost is a textbook number. A real lender sets it from loss and margin.
  • Not credit advice.

The whole card. Build your own applicant.

All nine characteristics and every bin, with the points the model gives. Tap one answer per row; it starts on our applicant.

The points table loads from scorecard_results.json.

Open the code, or score someone yourself.