Credit scoring: scorecards and logistic regression
A scorecard turns an applicant's file into points a person can read aloud. Define bad badly, or test it on the wrong months, and it looks better than it is
You fit a scorecard on 543 loans from applications up to 31 March (53 went bad). On those same loans its AUC is 0.727. You then score the 3,102 loans from April to June (278 went bad). What AUC do you expect on the later loans?
A scorecard is a table of attributes and points, as chapter AI in lending described it: an applicant’s answers earn points, the points add up, and a cut-off turns the total into a decision. That chapter built one by eye. This chapter builds one from data, the way a lender’s analysts do. It follows the usual order: decide what counts as bad, build a sample, bin the features, measure how much each tells you, fit a model, scale it to points, test it on later months and write the reasons for a low score.
The lab uses the loan book of the lab’s fictional wallet company, Owoleaf, as a stand-in for the lender’s own data. All prices, fees and cut-offs in it are illustrative.
What an application scorecard predicts
An application scorecard scores a person at the moment they apply, from what the lender can see then: the bureau report, the lender’s own history with the customer, the wallet’s activity. It predicts one thing: the chance the loan goes bad. A behaviour scorecard scores existing customers from how they have paid, and a collection scorecard ranks who to call first. They use the same method with different data and different outcomes.
Two properties matter for everything that follows. The score ranks; it does not decide. A card that puts applicants in the right order is useful even if its probabilities are off, because the lender chooses where to cut. And the card sees only features known at application. If a feature uses anything from after the loan was made, the model has read the answer, which the lab’s break step shows.
Define bad before you model
Every later number depends on this choice, so make it first and write it down. A definition of bad has three parts.
The event. The usual choice is 90 or more days past due (DPD), the days since the oldest unpaid instalment fell due, as the loan lifecycle defines it. Why not 30 days? A borrower who is a month late may pay soon after, so 30+ catches forgetfulness as well as default. Why not wait for write-off at 180? You would wait twice as long for each outcome and have fewer loans old enough to use. At 90 days the oldest unpaid instalment is three months overdue. This is a convention, not a law, and a lender must be able to say why it chose its own.
The window. Loans differ in age. A loan made in January has had nine months to go bad; one made in June has had four. If you count “bad at the cut-off”, old loans have more time to fail than new ones, and a feature that looks safe may be safe only because its loans are young. The fix is one observation window for everyone: a loan is bad if it reached 90+ DPD within 120 days of disbursement. The lab uses 120 days because it is the longest window that every loan in the book has been watched for: the last loans were made at the end of June, and the book is observed to 28 October.
Maturity. A loan watched for less than the window is immature: you cannot yet say it is good, only that it has not failed so far. Immature loans leave the sample. The lab’s first table shows the price of a longer window. At 150 days 1,471 of 3,645 loans are immature, and at 180 days 2,441 are, so a longer window means fewer loans to learn from, and those are the older ones.
Two loans in the book show the rules. L000002 is a salary advance (SAL) of ₦17,000 disbursed on 16 April, repayable as ₦17,850 on 16 May. It never paid. 90 days after the due date is 14 August, and the 120-day window ends on 14 August too (16 April plus 120 days). The loan is bad, on the last day it could be. L000071 is a three-instalment SME loan disbursed on 30 April. It paid two instalments and missed the third, due 29 July. By the cut-off it is 91 days past due, so its status says default. But 90 days after 29 July is 27 October, long after the window closed on 28 August. In this target it is good. The window has a cost: it sees early failures and misses late ones. In this book 331 loans are bad inside the window, against 368 at the cut-off.
The window also shapes what the card learns. Of the 331 bad loans, 281 are salary advances, and the same 281 are 90+ days past due at the cut-off: salary advances are 54% of the loans (1,959 of 3,645) and the riskiest product, at 14.3% bad. The window does cost the other products their later failures: BNPL goes from 66 loans at 90+ days at the cut-off to 40 bad in the window, personal loans from 14 to 9 and SME from 7 to 1, because only a first or second instalment can fail inside 120 days. A card built on this target is mainly learning who fails to repay a salary advance. Lenders handle this with a card per product or a longer window; this chapter keeps one card, leaves the product out of its features, and treats that as a limitation. The bureau-score thin-file bin and KYC tier may partly stand in for product (30% of salary-advance loans are thin files, none of the SME loans are), and the card is not tested product by product.
Classes in between, such as 30 to 89 days past due, are called indeterminate. Some lenders drop them from the sample; here they count as good, because a loan that is 60 days late at the window’s end has not reached the definition.
Sample and time
The sample is every approved loan that the customer took up: 3,645 of 8,386 applications. The other 4,741 are declined (4,521) or withdrawn (220), and have no outcome. Keep that in mind; the last section returns to it.
Split by time, not at random. Applications before 1 April train the card (543 loans, 53 bad). Applications from 1 April test it (3,102 loans, 278 bad). A lender uses its card on future applicants, whose mix and conditions will differ from the past, and a random split mixes the future into the training data. It also flatters, because two loans from the same customer, or from the same week, resemble each other. The cost is a small training set: 53 bad loans is thin, and a lender with so few would wait or accept that the card is provisional. Scorecard texts ask for far more bad loans than this before they trust a card’s weights (the Reading list has them). The small train set here is a deliberate hardship, and it is why the test result falls.
Binning, weight of evidence and information value
A scorecard works on bins, not raw numbers. A bureau score of 683 becomes “640 to 699”. Bins make the model readable, cope with outliers and missing values, and let a relationship that is not a straight line (a score of 740 is worth more than the step from 700 to 739 suggests) be expressed.
For each bin, compute its weight of evidence (WoE):
WoE = ln( share of all good loans that sit in the bin / share of all bad loans that sit in the bin )
A positive WoE means the bin holds more of the goods than of the bads: safer than average. Take the bureau-score bin “740+” from the lab’s training sample. The 543 loans split into 490 good and 53 bad. The bin holds 147 goods and 3 bads. Add half a loan to every cell, so that an empty cell never gives ln(0); with five bins that makes 492.5 goods and 55.5 bads in all. The good share is 147.5 / 492.5 = 0.2995 and the bad share is 3.5 / 55.5 = 0.0631. Their ratio is 4.75, and ln 4.75 = 1.56. The lab prints 1.56.
The information value (IV) of a feature adds up, over its bins, (good share minus bad share) times WoE. It measures how far apart the goods and bads are spread over the bins. A common rule of thumb: below 0.02 the feature is useless, 0.02 to 0.1 weak, 0.1 to 0.3 medium, 0.3 to 0.5 strong, and above 0.5 suspicious: check for leakage before celebrating. It is a rule of thumb, not a test, and the thresholds differ between books.
IV is not the only filter, and the lab applies a second one: monotonicity. If more years of credit history is safer, WoE should rise bin by bin. A feature whose WoE zigzags (a middle bin worse than both neighbours) is usually noise, and a scorecard with a zigzag has a reason code nobody can defend: “you lost points for having two to four years of history, but not for one”. In the lab, the enquiries and history features have IV above 0.1 on the training loans but fail the monotone check, and the card drops them. They were noise from 53 bad loans. In a trial fit that keeps both, the train AUC rises to 0.746 and the test AUC falls to 0.665, from 0.678: the extra features fitted the training loans and hurt on new ones.
Two more details. A thin file is a customer the bureau has little or no data on; in this book 129 of the 543 training loans (24%) are thin, and 18.6% of them went bad against 9.8% overall. The bureau-score feature gives thin files a bin of their own. For the other bureau features a thin file has no value at all, so its WoE is set to 0: no information, neither good nor bad. And binning is a judgement. The edges in the lab (640, 700, 740) are chosen to be round and to leave enough loans in each bin; another analyst would choose differently. Check each bin has some bad loans, and merge neighbours when it does not.
From WoE to a model
The model is a logistic regression: it predicts the log-odds of bad as an intercept plus a weighted sum of the features, here each feature’s WoE:
ln( P(bad) / P(good) ) = intercept + b1 x WoE1 + b2 x WoE2 + ...
Fitting finds the weights that make the training loans most probable. There is no closed form, so the lab’s fit_logistic uses Newton’s method: start from zero weights, compute the gradient and the curvature of the fit, and take a step. It settles in about six steps here; the code allows 30. It needs a small linear solver, which is also in the file. The code is standard-library Python; scikit-learn would do it in one line; the loop is written out here so you can see the gradient.
Because WoE is already on the side of good, and the model predicts the risk of bad, the weights should come out negative. A feature on its own, with well estimated bins, would get a weight near minus 1; features that overlap share the load, so each gets less. The lab prints −0.87 for the bureau score, −0.59 for delinquencies, −0.55 for KYC tier and −0.53 for wallet inflow. All are negative, as common sense says; a positive weight on a feature whose WoE is meant to help would warn you that two features overlap and one is fighting the other. A feature the lab dropped, open loans, shows it: with an IV of 0.006 it got a weight of +1.58 in a trial fit, the wrong way round.
Scaling to points
Log-odds are not friendly to a credit officer. Scorecards turn them into points with two choices and one formula. You choose a base: here 600 points at odds of 20 to 1 good to bad. You choose the points to double the odds (PDO): here 20. Then
score = offset + factor x ln(odds good:bad)
factor = PDO / ln 2 = 20 / 0.6931 = 28.85
offset = 600 - factor x ln 20 = 600 - 28.85 x 2.9957 = 513.56
Check it by hand: at odds 20:1 the score is 513.56 + 28.85 × 2.9957 = 600. At 40:1 it is 513.56 + 28.85 × 3.6889 = 620.0: 20 points more for double the odds. Here is what scores mean in the lender’s terms:
| Points | Odds good:bad | Chance of bad |
|---|---|---|
| 600 | 20 : 1 | 1 in 21, 4.8% |
| 580 | 10 : 1 | 1 in 11, 9.1% |
| 560 | 5 : 1 | 1 in 6, 16.7% |
| 540 | 2.5 : 1 | 1 in 3.5, 28.6% |
To put points on each bin, multiply its WoE by its feature’s weight and the factor, and share the intercept and the offset equally between the features. For the tier 3 bin: the share is (513.56 + 28.85 × 2.24) / 4 = 144.5, and 144.5 + 28.85 × 0.55 × 0.98 = 160.0. The card gives 160. Points are then rounded to whole numbers, which moves a score by a point or two and does not change the story. A feature with no data (a thin file on delinquencies) scores the neutral 145, the share of the intercept.
The result is a table of the kind chapter 1.6 built by eye. Every row can be read aloud, audited by a new analyst and checked by hand.
Validating the card
Three numbers say how well a card ranks.
- AUC, the area under the ROC curve: pick one bad and one good loan at random; the AUC is the chance the bad one has the lower score. 0.5 is a coin flip, 1.0 is perfect.
- Gini is 2 × AUC − 1, the same information on a 0 to 1 scale. The lab’s test AUC of 0.678 is a Gini of 0.356.
- KS (Kolmogorov–Smirnov) is the biggest gap between the cumulative share of bads and of goods when you sort from riskiest to safest. A KS of 0.29 means that at the best cut-off, a given share of the riskiest loans holds 29 points more of the bads than of the goods.
Quote the test figures. A card shows 0.727 on its own loans and 0.678 on later ones, and the 0.05 gap is the price of fitting 53 bad loans. A smaller gap with a larger training set is what a lender should expect; a gap much larger than this one points to overfitting, bins that were too fine, or a population that moved.
A second check is the bad rate by band. Cut the train scores into five equal groups, keep those edges, and look at the bad rate in each band for train and for test. A good card is monotone in both. The lab’s is, but it is also over-confident at the extremes: the lowest band has a bad rate of 24.8% on train and 17.8% on test, and the highest 0.9% against 3.1%. That is the usual shape: the best and worst bins were picked partly for their luck. A card that ranks well is not the same as a card whose probabilities are right; checking probabilities (calibration) belongs to the project in this module.
Last, compare with what you have. The lender already buys the bureau score. On the same test loans, that score alone, with thin files treated as the lowest, gets an AUC of 0.648. The card gets 0.678. That is a gain, a small one, and in this run it comes from KYC tier, which the bureau cannot see: refit without it (the names list in step 3) and the test AUC falls to 0.654, below the bureau score alone, while dropping wallet inflow leaves it at 0.678. Whether 0.03 of AUC is worth a team to maintain the card is a business decision: chapter 2.4 shows how scores feed cut-offs and prices.
Reasons for a low score
A declined customer asks why. A scorecard can answer without a model of the model, because each row’s points are visible. Take the points a feature lost compared with the best bin of that feature, sort them, and give the top two or three as reason codes. In the lab the three lowest-scoring applicants each score 544, and each lost 58 points on the bureau score (a thin file) and 24 on KYC tier: “no bureau history” and “identity verified at a low level”. The lender then writes each code in plain words, which a person approves once, not for each customer.
Reason codes have limits. They say what the card weighed, not what caused the borrower’s behaviour. When features overlap, the points a feature lost depend on which of the overlapping ones is in the card. They are also only as honest as the features: a card that uses a proxy for something the lender should not use gives a reason code that hides it. Chapter 1.6 and the later chapter on explaining declines (2.8) cover what a customer is owed when an automated model decides.
Nor is every feature allowed. Law-firm and press summaries of the FCCPC’s Digital, Electronic, Online or Non-Traditional Consumer Lending Regulations, 2025 say that lenders must confirm their apps do not access a borrower’s contacts, call logs or photos; the FCCPC’s own guidelines document is reported to use similar languageas of 2026-11. That wording comes from search summaries, which differ on dates and detail, not from a reading of the regulation, and the lab does not use such data. Read the Regulations’ own text before you decide a feature is permitted, and chapter 2.3 and 2.7 return to what a lender may collect.
What a scorecard cannot see
The lab’s last step prints the limits. They are the reason a card is a tool and not an oracle.
Applicants the old rule declined. The card was fitted on loans the lender approved, under cut-offs on bureau score, delinquencies and enquiries. The lowest bureau score among the 3,645 approved loans is 561, and none has two or more delinquencies, because the rule declined them. The card knows nothing about those regions. Since 1 April the lender has declined 4,070 applications and observed no outcome on any. The card puts 2,667 of them (66%) above its bottom-band edge, which says they look acceptable to it, but nobody knows whether they would have repaid. Many were not credit declines: 1,969 asked for less than the product minimum and 1,037 lacked income evidence; only 894 fell below a bureau cut-off. Guessing how declined applicants would have behaved is called reject inference; it has no clean answer, and the chapter on model risk in module 3 treats it. The honest fix is cheap: approve a small random sample of applicants below the cut-off, with a cap, and learn their outcomes.
A window and a mix. The target is early failure, mostly on salary advances. A card built on 120 days says little about a 12-month loan failing at instalment ten.
Time. The card was trained on January to March, when the book had 62, 283 and 676 applications a month and was only starting. By June the lender had 3,791. Customers who join later may differ. Monitoring this drift, the population stability index, is part of the project. One more caution: kyc_tier comes from the customer table, where it does not change in this lab; a real lender must use the tier as it stood on the application day.
Fairness. A card can rank well and still disadvantage a group, for example through a feature like state or channel that proxies for something else. Module 3 tests for that.
Back at the lender
Tobechukwu and Onyekachi agree on how to present the result: the card’s test AUC is 0.678, against 0.648 for the bureau score alone; its bands rank in order on both train and test; its top reasons for the lowest scores are “no bureau history” and “low KYC tier”; and it is blind to everyone the old rule declined. They decide to run it beside the existing cut-offs without letting it decide anything, for a quarter. Then they will have outcomes to compare, and a plan for the declined.
You build a scorecard in one file, scorecard.py, adding to it step by step. Keep the file as written: step 7 imports it. The project, chapter 2.9 (Build and validate a scorecard), builds and validates its own salary-advance scorecard and does not import this one. Work in labs/finance. Do not open data1/answers/loans_truth.csv: a real lender has no file that says who was always going to default, and a model trained on it would be cheating. Money is in integer kobo; every price and figure is illustrative.
0. Build the scale 1 book once. The modelling chapters need more bad loans than the default folder has (36 at scale 0.1, 368 at scale 1). If data1/finance.sqlite is missing, build it. It takes about 40 seconds and writes about 720 MB, so check the disk first.
python3 generate.py --scale 1 --out data1 && python3 loans.py --out data1 \
&& python3 cards.py --out data1 && python3 collect.py --out data1
python3 check.py --db data1/finance.sqliteloan book: 3645 loans, 9,771,721,819 kobo of principal outstanding; checks 7-11 run
card book: 100,972 card attempts, 1065 disputes for 1,189,430,900 kobo; checks 12-15 run
collections: 15,831 actions, 1274 promises, 368 placements; checks 16-18 run
...
OK: all invariants holdThe end of check.py’s output; two account lines between are left out. It takes about 30 seconds. 3,645 loans and 368 collection placements are the scale 1 figures the modelling chapters quote.
1. Define bad and build the sample. Save this as scorecard.py. It reads the book read-only, rebuilds each loan’s payments, and marks a loan bad if an instalment was still unpaid 90 days after its due date and that day falls inside the window. It also adds the wallet money received in the 60 days before each application, from transactions.
"""scorecard.py: an application scorecard on the lab's loan book (data1, scale 1).
Standard library only. Money is integer kobo. Every figure is illustrative.
Step 7 and the break step import this file: `import scorecard as s`.
"""
import collections
import datetime as dt
import functools
import math
import sqlite3
DB = "data1/finance.sqlite"
CUT_OFF = dt.date(2026, 10, 28) # the loan book is observed to here
WINDOW_DAYS = 120 # bad = 90+ days past due within this many days of disbursement
TRAIN_BEFORE = "2026-04-01" # applications before this date train the card; the rest test it
BASE_SCORE, BASE_ODDS, PDO = 600, 20, 20 # 600 points = 20:1 good:bad; every 20 points doubles the odds
def day(text):
return dt.date.fromisoformat(text[:10])
@functools.lru_cache(maxsize=1)
def _raw(db_path=DB):
"""Every approved loan with what was known at application time, plus its instalments and payments."""
db = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True)
loans = db.execute("""
SELECT l.id, a.id, a.applied_at, l.disbursed_at, l.product, l.status, l.days_past_due,
b.hit, b.score, b.delinquent_12m, b.enquiries_90d, b.history_years, b.open_loans,
c.kyc_tier, c.id
FROM loans l JOIN applications a ON a.id = l.application_id
JOIN bureau_reports b ON b.id = a.bureau_report_id
JOIN customers c ON c.id = l.customer_id ORDER BY l.id""").fetchall()
due = collections.defaultdict(list)
for loan_id, n, due_date, total in db.execute("SELECT loan_id, instalment, due_date, total_kobo FROM schedule"):
due[loan_id].append((n, day(due_date), total))
paid = collections.defaultdict(list)
for loan_id, n, when, amount, late_fee in db.execute(
"SELECT loan_id, instalment, paid_at, amount_kobo, late_fee_kobo FROM repayments"):
paid[(loan_id, n)].append((day(when), amount - late_fee)) # late fees are not part of the instalment
wallet = {}
for row in loans: # wallet money in during the 60 days before the application day
applied, customer = row[2], row[14]
wallet[row[0]] = db.execute("""SELECT COALESCE(SUM(amount_kobo), 0) FROM transactions
WHERE customer_id = ? AND status = 'succeeded' AND kind IN ('funding_transfer', 'funding_card')
AND created_at < ? AND created_at >= date(?, '-60 day')""", (customer, applied, applied)).fetchone()[0]
return loans, due, paid, wallet
def went_bad(loan_id, disbursed, window, due, paid):
"""1 if some instalment was still unpaid 90 days after its due date, and that day falls inside the window."""
last_day = min(disbursed + dt.timedelta(days=window), CUT_OFF)
for n, due_date, total in due[loan_id]:
check = due_date + dt.timedelta(days=90)
if check <= last_day and sum(a for when, a in paid[(loan_id, n)] if when <= check) < total:
return 1
return 0
def load_sample(window_days=WINDOW_DAYS, db_path=DB):
"""One dict per loan observed for the whole window. Loans observed for less are immature and left out."""
loans, due, paid, wallet = _raw(db_path)
rows = []
for (loan_id, app_id, applied, disbursed, product, status, dpd, hit, score, dq, enq, hist, open_loans,
tier, customer) in loans:
if day(disbursed) + dt.timedelta(days=window_days) > CUT_OFF:
continue
rows.append(dict(loan_id=loan_id, application_id=app_id, applied_at=applied, product=product,
hit=hit, score=score, delinquent_12m=dq, enquiries_90d=enq, history_years=hist,
open_loans=open_loans, kyc_tier=tier, wallet_in_60d=wallet[loan_id],
bad=went_bad(loan_id, day(disbursed), window_days, due, paid)))
return rows
def split(rows):
"""Out of time: train on applications before TRAIN_BEFORE, test on the later ones."""
return ([r for r in rows if r["applied_at"] < TRAIN_BEFORE],
[r for r in rows if r["applied_at"] >= TRAIN_BEFORE])
def show_sample():
total = len(_raw()[0])
print(f"approved loans in the book: {total}")
print("window mature immature bad bad rate")
for w in (90, 120, 150, 180):
rows = load_sample(w)
bad = sum(r["bad"] for r in rows)
print(f"{w:>5}d {len(rows):>7} {total - len(rows):>9} {bad:>4} {bad / len(rows):.1%}")
status_bad = sum(1 for r in _raw()[0] if r[6] >= 90)
print(f"for comparison, loans 90+ days past due at the cut-off: {status_bad}")
rows = load_sample()
print(f"bad loans inside the {WINDOW_DAYS}-day window, by product:")
for product in ("SAL", "PL", "BNPL", "SME"):
part = [r for r in rows if r["product"] == product]
bad = sum(r["bad"] for r in part)
print(f" {product:<5}{len(part):>6} loans {bad:>4} bad ({bad / len(part):.1%})")
train, test = split(rows)
for name, part in (("train", train), ("test", test)):
bad = sum(r["bad"] for r in part)
print(f"{name}: {len(part)} loans, {bad} bad ({bad / len(part):.1%}), "
f"applied {min(r['applied_at'] for r in part)} to {max(r['applied_at'] for r in part)}")Run the first report.
python3 -c "import scorecard as s; s.show_sample()"approved loans in the book: 3645
window mature immature bad bad rate
90d 3645 0 0 0.0%
120d 3645 0 331 9.1%
150d 2174 1471 231 10.6%
180d 1204 2441 136 11.3%
for comparison, loans 90+ days past due at the cut-off: 368
bad loans inside the 120-day window, by product:
SAL 1959 loans 281 bad (14.3%)
PL 451 loans 9 bad (2.0%)
BNPL 766 loans 40 bad (5.2%)
SME 469 loans 1 bad (0.2%)
train: 543 loans, 53 bad (9.8%), applied 2026-01-12 to 2026-03-31
test: 3102 loans, 278 bad (9.0%), applied 2026-04-01 to 2026-06-27No loan is bad at 90 days, because the earliest a loan can be 90 days late is 104 days after disbursement (a BNPL loan’s first instalment falls due at day 14). At 120 days every loan has been watched for the whole window, so none is immature and 331 are bad. At 150 and 180 days the sample shrinks and the bad rate rises. The 368 loans that are 90+ days past due at the cut-off differ from the 331 because 37 of them reached 90 days only after their window closed, such as L000071 in the chapter. Salary advances are 281 of the 331 bad loans. Train has 53 bad loans and test has 278.
2. Bin the features and keep the ones that earn it. Add this to the end of scorecard.py. It defines the candidate features, the weight of evidence and information value of each bin, a check that WoE moves the way common sense says, and a review that keeps or drops each feature using the training loans only.
# ---- bins, weight of evidence and information value --------------------------------------------
# Each feature maps a row to a bin label (labels sort in the order of the bins), or None when the
# bureau has no data (a thin file). `direction` is what common sense expects of WoE as the bins go up:
# +1 safer, -1 riskier.
def _score_bin(r):
if not r["hit"]:
return "thin file"
s = r["score"]
return "1: under 640" if s < 640 else "2: 640-699" if s < 700 else "3: 700-739" if s < 740 else "4: 740+"
def _wallet_bin(r):
k = r["wallet_in_60d"]
return "1: under ₦25,000" if k < 2_500_000 else "2: ₦25,000-199,999" if k < 20_000_000 else "3: ₦200,000+"
FEATURES = {
"bureau_score": (_score_bin, +1),
"delinquent_12m": (lambda r: None if not r["hit"] else f"{min(r['delinquent_12m'], 1)}", -1),
"enquiries_90d": (lambda r: None if not r["hit"] else
"1: 0-1" if r["enquiries_90d"] <= 1 else "2: 2-3" if r["enquiries_90d"] <= 3 else "3: 4+", -1),
"history_years": (lambda r: None if not r["hit"] else
"1: 0-1" if r["history_years"] <= 1 else "2: 2-4" if r["history_years"] <= 4 else "3: 5+", +1),
"open_loans": (lambda r: None if not r["hit"] else
"1: 0-1" if r["open_loans"] <= 1 else "2: 2-3" if r["open_loans"] <= 3 else "3: 4+", -1),
"kyc_tier": (lambda r: f"tier {r['kyc_tier']}", +1),
"wallet_in_60d": (_wallet_bin, +1),
}
def woe_table(rows, name):
"""{bin: (loans, bad, woe)} and the feature's information value.
WoE = ln(share of all goods in the bin / share of all bads in the bin); half a loan is added to
every cell so an empty cell does not give ln(0). IV = sum of (good share - bad share) x WoE."""
bin_of = FEATURES[name][0]
count = collections.defaultdict(lambda: [0, 0]) # bin -> [good, bad]
for r in rows:
b = bin_of(r)
if b is not None:
count[b][r["bad"]] += 1
k = len(count)
goods = sum(c[0] for c in count.values()) + 0.5 * k
bads = sum(c[1] for c in count.values()) + 0.5 * k
table, iv = {}, 0.0
for b in sorted(count):
g, d = count[b]
pg, pb = (g + 0.5) / goods, (d + 0.5) / bads
table[b] = (g + d, d, math.log(pg / pb))
iv += (pg - pb) * math.log(pg / pb)
return table, iv
def is_monotone(table, direction):
"""Do the WoE values rise (direction +1) or fall (-1) as the numbered bins go up? 'thin file' is left out."""
woes = [w for b, (_, _, w) in sorted(table.items()) if b != "thin file"]
steps = [(b - a) * direction for a, b in zip(woes, woes[1:])]
return all(s >= 0 for s in steps)
MIN_IV = 0.02
def review_variables(train):
"""Keep a feature if its IV is at least MIN_IV and its WoE moves the way common sense says."""
keep = []
for name, (_, direction) in FEATURES.items():
table, iv = woe_table(train, name)
mono = is_monotone(table, direction)
verdict = "keep" if iv >= MIN_IV and mono else "drop: weak" if iv < MIN_IV else "drop: not monotone"
if verdict == "keep":
keep.append(name)
print(f"{name:<16} IV {iv:.3f} monotone {'yes' if mono else 'no ':<3} -> {verdict}")
return keep
def show_bins(train, name):
table, iv = woe_table(train, name)
print(f"{name}: IV {iv:.3f}")
print(f" {'bin':<22}{'loans':>6}{'bad':>5}{'bad rate':>10}{'WoE':>7}")
for b, (n, d, w) in table.items():
print(f" {b:<22}{n:>6}{d:>5}{d / n:>10.1%}{w:>7.2f}")python3 -c "import scorecard as s; train, test = s.split(s.load_sample()); s.review_variables(train); print(); s.show_bins(train, 'bureau_score'); print(); s.show_bins(train, 'wallet_in_60d')"bureau_score IV 0.573 monotone yes -> keep
delinquent_12m IV 0.050 monotone yes -> keep
enquiries_90d IV 0.130 monotone no -> drop: not monotone
history_years IV 0.132 monotone no -> drop: not monotone
open_loans IV 0.006 monotone yes -> drop: weak
kyc_tier IV 0.286 monotone yes -> keep
wallet_in_60d IV 0.122 monotone yes -> keep
bureau_score: IV 0.573
bin loans bad bad rate WoE
1: under 640 73 10 13.7% -0.38
2: 640-699 115 11 9.6% 0.02
3: 700-739 76 5 6.6% 0.38
4: 740+ 150 3 2.0% 1.56
thin file 129 24 18.6% -0.72
wallet_in_60d: IV 0.122
bin loans bad bad rate WoE
1: under ₦25,000 136 21 15.4% -0.52
2: ₦25,000-199,999 268 22 8.2% 0.19
3: ₦200,000+ 139 10 7.2% 0.31Four features pass. Enquiries and history have IV above 0.1 but zigzag: on 53 bad loans a middle bin got lucky. Open loans is weak. Check the 740+ bin of the bureau score against the chapter’s arithmetic: 3 bad of 150 loans, WoE 1.56. Thin files (129 loans, 18.6% bad) are the riskiest bin.
The bureau score’s IV of 0.573 is above the 0.5 line from earlier in the chapter, so it trips the rule and you owe it the leakage check rather than a celebration. Ask two questions of the feature. First, was it known at application time? Look at where the value comes from: the lab’s load_sample reads it from the bureau_reports row that the application points to, and that report is dated at the application. Second, is it derived from the outcome? A leaking feature is computed from what happened after the loan (days past due, a collections flag, a write-off); the bureau score is the bureau’s view of the borrower’s past with other lenders, so it cannot contain how this loan turned out. Both answers clear it here, and the IV is high because the score is the strongest honest signal in the lab data. The dpd_now test at the end of the chapter shows what a real leak looks like by comparison: it fails the first question outright. A high IV is a reason to run the check, not proof of a leak.
3. Fit the model. Add this. fit_logistic is Newton’s method for logistic regression with a small linear solver; auc and ks measure ranking.
# ---- logistic regression on the WoE values, and two measures of ranking ------------------------
def solve(a, b):
"""Solve a x = b by Gaussian elimination with partial pivoting (a is small)."""
n = len(b)
m = [row[:] + [b[i]] for i, row in enumerate(a)]
for i in range(n):
p = max(range(i, n), key=lambda r: abs(m[r][i]))
m[i], m[p] = m[p], m[i]
for r in range(i + 1, n):
f = m[r][i] / m[i][i]
for c in range(i, n + 1):
m[r][c] -= f * m[i][c]
x = [0.0] * n
for i in range(n - 1, -1, -1):
x[i] = (m[i][n] - sum(m[i][j] * x[j] for j in range(i + 1, n))) / m[i][i]
return x
def fit_logistic(x, y, ridge=1e-6, steps=30):
"""Newton's method for P(bad) = 1 / (1 + exp(-(b . x))). x rows start with a 1 for the intercept."""
n = len(x[0])
b = [0.0] * n
for _ in range(steps):
grad = [0.0] * n
hess = [[0.0] * n for _ in range(n)]
for xi, yi in zip(x, y):
p = 1 / (1 + math.exp(-sum(bj * v for bj, v in zip(b, xi))))
for i in range(n):
grad[i] += (yi - p) * xi[i]
for j in range(n):
hess[i][j] += p * (1 - p) * xi[i] * xi[j]
for i in range(n):
hess[i][i] += ridge
step = solve(hess, grad)
b = [bj + sj for bj, sj in zip(b, step)]
if max(abs(s) for s in step) < 1e-9:
break
return b
def woe_maps(train, names):
return {n: {b: w for b, (_, _, w) in woe_table(train, n)[0].items()} for n in names}
def design(rows, names, woe):
"""Rows of [1, WoE of each feature]. A missing bin (thin file) or unseen bin gets WoE 0: no information."""
out = []
for r in rows:
line = [1.0]
for n in names:
b = FEATURES[n][0](r)
line.append(woe[n].get(b, 0.0) if b is not None else 0.0)
out.append(line)
return out
def fit_card(train, names):
woe = woe_maps(train, names)
b = fit_logistic(design(train, names, woe), [r["bad"] for r in train])
return dict(names=names, woe=woe, intercept=b[0], coef=dict(zip(names, b[1:])))
def log_odds_bad(card, rows):
x = design(rows, card["names"], card["woe"])
b = [card["intercept"]] + [card["coef"][n] for n in card["names"]]
return [sum(bj * v for bj, v in zip(b, xi)) for xi in x]
def auc(risk, bad):
"""Chance that a random bad loan has a higher risk than a random good one (ties count half)."""
order = sorted(range(len(risk)), key=lambda i: risk[i])
ranks, i = [0.0] * len(risk), 0
while i < len(order):
j = i
while j + 1 < len(order) and risk[order[j + 1]] == risk[order[i]]:
j += 1
for k in range(i, j + 1):
ranks[order[k]] = (i + j) / 2 + 1
i = j + 1
n_bad = sum(bad)
n_good = len(bad) - n_bad
return (sum(rk for rk, y in zip(ranks, bad) if y) - n_bad * (n_bad + 1) / 2) / (n_bad * n_good)
def ks(risk, bad):
"""Largest gap between the share of bads and the share of goods at or below a risk level."""
n_bad = sum(bad)
n_good = len(bad) - n_bad
cum_bad = cum_good = best = 0.0
pairs = sorted(zip(risk, bad), reverse=True) # riskiest first
for k, (value, y) in enumerate(pairs):
cum_bad += y / n_bad
cum_good += (1 - y) / n_good
if k + 1 == len(pairs) or pairs[k + 1][0] != value:
best = max(best, cum_bad - cum_good)
return best
def show_model(train, test, names):
card = fit_card(train, names)
print(f"{'term':<16}{'coefficient':>12}")
print(f"{'intercept':<16}{card['intercept']:>12.2f}")
for n in names:
print(f"{n:<16}{card['coef'][n]:>12.2f}")
for label, rows in (("train", train), ("test", test)):
risk = log_odds_bad(card, rows)
print(f"{label}: AUC {auc(risk, [r['bad'] for r in rows]):.3f} KS {ks(risk, [r['bad'] for r in rows]):.3f}")
raw = [-(r["score"] if r["hit"] else 500) for r in test]
print(f"test, bureau score alone (thin file as 500): AUC {auc(raw, [r['bad'] for r in test]):.3f}")
return cardpython3 -c "import scorecard as s; train, test = s.split(s.load_sample()); s.show_model(train, test, ['bureau_score', 'delinquent_12m', 'kyc_tier', 'wallet_in_60d'])"term coefficient
intercept -2.24
bureau_score -0.87
delinquent_12m -0.59
kyc_tier -0.55
wallet_in_60d -0.53
train: AUC 0.727 KS 0.350
test: AUC 0.678 KS 0.294
test, bureau score alone (thin file as 500): AUC 0.648Every weight is negative, as it should be. The test AUC of 0.678 is below the train AUC of 0.727, the price of 53 bad loans, and above the bureau score’s 0.648. KS falls from 0.350 to 0.294.
4. Scale to points. Add this. It turns the weights into whole points: 600 at odds of 20:1, 20 points to double the odds.
# ---- scaling to points ---------------------------------------------------------------------------
def add_points(card):
"""Score = offset + factor x ln(odds good:bad). `factor` is PDO / ln 2, so PDO points double the odds.
ln(odds good) = -(intercept + sum of coef x WoE); the intercept is shared equally between the features."""
factor = PDO / math.log(2)
offset = BASE_SCORE - factor * math.log(BASE_ODDS)
share = (offset - factor * card["intercept"]) / len(card["names"])
card["factor"], card["offset"], card["neutral"] = factor, offset, round(share)
card["points"] = {n: {b: round(share - factor * card["coef"][n] * w) for b, w in card["woe"][n].items()}
for n in card["names"]}
return card
def build_card(train, names):
return add_points(fit_card(train, names))
def feature_points(card, row, name):
b = FEATURES[name][0](row)
return card["points"][name].get(b, card["neutral"]) if b is not None else card["neutral"]
def score(card, row):
"""Whole points, higher is safer."""
return sum(feature_points(card, row, n) for n in card["names"])
def show_card(card, train):
print(f"base {BASE_SCORE} points = odds {BASE_ODDS}:1 good:bad; {PDO} points double the odds "
f"(factor {card['factor']:.2f}, offset {card['offset']:.2f})")
print(f"{'feature':<16}{'bin':<22}{'loans':>6}{'bad rate':>10}{'points':>8}")
for n in card["names"]:
table, _ = woe_table(train, n)
for b, (count, bad, _) in table.items():
print(f"{n:<16}{b:<22}{count:>6}{bad / count:>10.1%}{card['points'][n][b]:>8}")
print(f"a feature with no data (thin file) scores the neutral {card['neutral']} points")
best = sum(max(card["points"][n].values()) for n in card["names"])
worst = sum(min(card["points"][n].values()) for n in card["names"])
print(f"lowest possible total {worst}, highest {best}")python3 -c "import scorecard as s; train, test = s.split(s.load_sample()); card = s.build_card(train, ['bureau_score', 'delinquent_12m', 'kyc_tier', 'wallet_in_60d']); s.show_card(card, train)"base 600 points = odds 20:1 good:bad; 20 points double the odds (factor 28.85, offset 513.56)
feature bin loans bad rate points
bureau_score 1: under 640 73 13.7% 135
bureau_score 2: 640-699 115 9.6% 145
bureau_score 3: 700-739 76 6.6% 154
bureau_score 4: 740+ 150 2.0% 184
bureau_score thin file 129 18.6% 126
delinquent_12m 0 283 6.0% 147
delinquent_12m 1 131 9.2% 140
kyc_tier tier 1 207 15.5% 136
kyc_tier tier 2 224 7.6% 149
kyc_tier tier 3 112 3.6% 160
wallet_in_60d 1: under ₦25,000 136 15.4% 137
wallet_in_60d 2: ₦25,000-199,999 268 8.2% 148
wallet_in_60d 3: ₦200,000+ 139 7.2% 149
a feature with no data (thin file) scores the neutral 145 points
lowest possible total 539, highest 640This is the card. Redo one row by hand: tier 3 is (513.56 + 28.85 × 2.24) / 4 = 144.5, plus 28.85 × 0.55 × 0.98 = 15.6, which rounds to 160. A thin file scores 126 on the bureau row because its own bin is the riskiest.
5. Validate out of time. Add this. It scores train and test with the whole-point card and prints the bad rate by band, with band edges taken from train only.
# ---- out-of-time validation ----------------------------------------------------------------------
def show_validation(card, train, test, bands=5):
for label, rows in (("train", train), ("test", test)):
risk = [-score(card, r) for r in rows]
bad = [r["bad"] for r in rows]
print(f"{label}: AUC {auc(risk, bad):.3f} Gini {2 * auc(risk, bad) - 1:.3f} KS {ks(risk, bad):.3f}")
ordered = sorted(score(card, r) for r in train)
cuts = [ordered[len(ordered) * k // bands] for k in range(1, bands)] # band edges come from train only
def band(points):
return sum(points >= c for c in cuts) # 0 = riskiest band
print(f"\nbands from the train score quintiles; bad rate in each band, train and test")
print(f"{'band':<12}{'points':<12}{'train':>6}{'bad':>7}{'test':>7}{'bad':>7}{'share of test bads':>20}")
total_bad = sum(r["bad"] for r in test)
for k in range(bands):
lo = cuts[k - 1] if k else None
hi = cuts[k] - 1 if k < bands - 1 else None
text = f"up to {hi}" if lo is None else f"{lo} and up" if hi is None else f"{lo}-{hi}"
tr_k = [r for r in train if band(score(card, r)) == k]
te_k = [r for r in test if band(score(card, r)) == k]
print(f"{k + 1:<12}{text:<12}{len(tr_k):>6}{sum(r['bad'] for r in tr_k) / max(len(tr_k), 1):>7.1%}"
f"{len(te_k):>7}{sum(r['bad'] for r in te_k) / max(len(te_k), 1):>7.1%}"
f"{sum(r['bad'] for r in te_k) / total_bad:>20.1%}")
return cutspython3 -c "import scorecard as s; train, test = s.split(s.load_sample()); card = s.build_card(train, ['bureau_score', 'delinquent_12m', 'kyc_tier', 'wallet_in_60d']); s.show_validation(card, train, test)"train: AUC 0.728 Gini 0.456 KS 0.350
test: AUC 0.678 Gini 0.356 KS 0.292
bands from the train score quintiles; bad rate in each band, train and test
band points train bad test bad share of test bads
1 up to 556 101 24.8% 405 17.8% 25.9%
2 557-575 106 10.4% 640 12.5% 28.8%
3 576-590 110 8.2% 753 10.5% 28.4%
4 591-616 116 6.0% 566 4.2% 8.6%
5 617 and up 110 0.9% 738 3.1% 8.3%The points are rounded, so train AUC moves from 0.727 to 0.728. Test Gini is 0.356. Bad rates fall from band 1 to band 5 on both sets. Band 1 is 24.8% on train and 17.8% on test, and band 5 is 0.9% and 3.1%: the extremes were partly luck.
6. Reasons, blind spots and the whole run. Add these two blocks to the end of the file. The first holds reason codes and the blind-spot report; the second, main, runs every step in order, so python3 scorecard.py prints the lot.
# ---- reason codes, and what the card cannot see --------------------------------------------------
REASONS = {
"bureau_score": "bureau score low or no bureau history",
"delinquent_12m": "late payments with other lenders in the last 12 months",
"kyc_tier": "identity verification at a low tier",
"wallet_in_60d": "low money coming into the wallet in the last 60 days",
"enquiries_90d": "many credit enquiries in the last 90 days",
"history_years": "short credit history",
"open_loans": "many open loans elsewhere",
}
def reason_codes(card, row, top=2):
"""Points lost against the best bin of each feature, largest first: the reasons for a low score."""
lost = []
for n in card["names"]:
shortfall = max(card["points"][n].values()) - feature_points(card, row, n)
if shortfall > 0:
lost.append((shortfall, n))
return [(n, s) for s, n in sorted(lost, reverse=True)[:top]]
def show_reasons(card, rows, how_many=3):
worst = sorted(rows, key=lambda r: (score(card, r), r["loan_id"]))[:how_many]
for r in worst:
print(f"application {r['application_id']} ({r['loan_id']}): {score(card, r)} points, "
f"outcome {'bad' if r['bad'] else 'good'}")
for n, lost in reason_codes(card, r):
print(f" -{lost:>3} points: {REASONS[n]}")
def load_declined(db_path=DB):
"""Applications the lender turned away from April on: features known, outcome never observed."""
db = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True)
rows = []
for (app_id, applied, hit, sc, dq, enq, hist, ol, tier, customer) in db.execute("""
SELECT a.id, a.applied_at, b.hit, b.score, b.delinquent_12m, b.enquiries_90d, b.history_years,
b.open_loans, c.kyc_tier, c.id
FROM applications a JOIN bureau_reports b ON b.id = a.bureau_report_id
JOIN customers c ON c.id = a.customer_id
WHERE a.decision = 'declined' AND a.applied_at >= ?""", (TRAIN_BEFORE,)):
wallet = db.execute("""SELECT COALESCE(SUM(amount_kobo), 0) FROM transactions
WHERE customer_id = ? AND status = 'succeeded' AND kind IN ('funding_transfer', 'funding_card')
AND created_at < ? AND created_at >= date(?, '-60 day')""", (customer, applied, applied)).fetchone()[0]
rows.append(dict(application_id=app_id, applied_at=applied, hit=hit, score=sc, delinquent_12m=dq,
enquiries_90d=enq, history_years=hist, open_loans=ol, kyc_tier=tier, wallet_in_60d=wallet))
return rows
def show_blind_spots(card, train, test, cuts):
approved = train + test
scores = [r["score"] for r in approved if r["hit"]]
print(f"lowest bureau score among {len(approved)} approved loans: {min(scores)}; "
f"loans scored under 560: {sum(s < 560 for s in scores)}")
print(f"loans with 2 or more delinquencies in 12 months: {sum(r['delinquent_12m'] >= 2 for r in approved)}")
declined = load_declined()
above = sum(score(card, r) >= cuts[0] for r in declined)
print(f"declined applications from {TRAIN_BEFORE}: {len(declined)}, outcome known for 0")
print(f" the card puts {above} of them ({above / len(declined):.0%}) above its bottom-band edge of {cuts[0]} points")
print(f" loans made from {TRAIN_BEFORE}: {len(test)}")def main():
rows = load_sample()
train, test = split(rows)
print("== 1. the sample ==")
show_sample()
print("\n== 2. the variables (train only) ==")
names = review_variables(train)
for name in names:
print()
show_bins(train, name)
print("\n== 3. the model ==")
show_model(train, test, names)
print("\n== 4. the card ==")
card = build_card(train, names)
show_card(card, train)
print("\n== 5. validation, out of time ==")
cuts = show_validation(card, train, test)
print("\n== 6. reasons for the three lowest scores in the test window ==")
show_reasons(card, test)
print("\n== 7. what the card cannot see ==")
show_blind_spots(card, train, test, cuts)
if __name__ == "__main__":
main()python3 scorecard.pyThe output starts with the sections you have already seen (1 to 5), then ends with:
== 6. reasons for the three lowest scores in the test window ==
application 186 (L000080): 544 points, outcome good
- 58 points: bureau score low or no bureau history
- 24 points: identity verification at a low tier
application 462 (L000191): 544 points, outcome good
- 58 points: bureau score low or no bureau history
- 24 points: identity verification at a low tier
application 584 (L000242): 544 points, outcome bad
- 58 points: bureau score low or no bureau history
- 24 points: identity verification at a low tier
== 7. what the card cannot see ==
lowest bureau score among 3645 approved loans: 561; loans scored under 560: 0
loans with 2 or more delinquencies in 12 months: 0
declined applications from 2026-04-01: 4070, outcome known for 0
the card puts 2667 of them (66%) above its bottom-band edge of 557 points
loans made from 2026-04-01: 3102The three lowest scores are thin-file, tier 1 applicants, each 544 points, and the reasons say so. The blind spots are the point: no approved loan has a bureau score under 560 or two delinquencies, and 4,070 declined applications since 1 April have no outcome, yet the card would put 66% of them above its bottom-band edge.
7. Reuse it. The later chapters import the file. Save this as reuse.py and run it. It scores one applicant and prints the facts a reviewer, or an AI assistant, would need to check the sum.
import scorecard as s
train, test = s.split(s.load_sample())
card = s.build_card(train, ["bureau_score", "delinquent_12m", "kyc_tier", "wallet_in_60d"])
row = test[0]
print({k: row[k] for k in ("application_id", "hit", "score", "delinquent_12m", "kyc_tier", "wallet_in_60d")})
print("points:", s.score(card, row), [(n, s.feature_points(card, row, n)) for n in card["names"]])python3 reuse.py{'application_id': 10, 'hit': 0, 'score': None, 'delinquent_12m': 0, 'kyc_tier': 1, 'wallet_in_60d': 12326200}
points: 555 [('bureau_score', 126), ('delinquent_12m', 145), ('kyc_tier', 136), ('wallet_in_60d', 148)]Application 10 has no bureau hit (126 points), no delinquency data (145), KYC tier 1 (136) and wallet inflow of 12,326,200 kobo, which is ₦123,262 (148): total 555. The wallet figure is in kobo.
Leak the answer. Save this as leak.py and run it. It adds the loan’s days past due at the cut-off, an outcome field, as a feature.
import scorecard as s
dpd_at_cut_off = {row[0]: row[6] for row in s._raw()[0]} # loans.days_past_due: an OUTCOME field
rows = s.load_sample()
for r in rows:
r["dpd_now"] = dpd_at_cut_off[r["loan_id"]]
s.FEATURES["dpd_now"] = (lambda r: "1: none" if r["dpd_now"] == 0 else "2: 1-89 days" if r["dpd_now"] < 90 else "3: 90+ days", -1)
train, test = s.split(rows)
s.show_model(train, test, ["bureau_score", "delinquent_12m", "kyc_tier", "wallet_in_60d", "dpd_now"])python3 leak.pyYou will see a test AUC of 0.996 and a KS of 0.990, where the honest card got 0.678 and 0.294. The delinquency weight even turns positive. A model that is nearly perfect on later loans has read the answer. It happened here because the feature is measured after the loan was made, and the same thing happens quietly in real lenders when a column is refreshed from the servicing system. When you see AUC above about 0.9 on a credit card, hunt for the leak first. Then try WINDOW_DAYS = 150 in scorecard.py and watch the sample shrink to 2,174 loans and the train set with it.
Template
# Scorecard development summary: <card name>, <lender>
Built by <analyst>, credit risk. Owner: <role>. Approved by <head of credit risk>.
## 1. Target
- Bad means: <event, e.g. 90+ days past due> within <n> days of disbursement
- Observed to: <cut-off date>. Loans watched for less than the window are left out: <count>
- Why this definition, and what it misses: <one or two sentences>
## 2. Sample and time windows
- Approved loans in the sample: <count> of <applications>; declined or withdrawn: <count>, no outcome
- Train: applications <from> to <to>, <loans> loans, <bad> bad (<rate>)
- Test: applications <from> to <to>, <loans> loans, <bad> bad (<rate>)
## 3. Variables and bins
| Variable | Bins | IV | Direction | Kept? Why |
Dropped variables listed with the reason (weak, not monotone, leakage risk).
## 4. Performance (test months, not train)
- AUC <x>, Gini <x>, KS <x>; train AUC <x>
- Bureau score alone on the same loans: AUC <x>
- Bad rate by band, train against test: <what holds, what does not>
## 5. Known limits
<what the card cannot see; one way it could be wrong and what would show it>
## 6. Decision and sign-off
Decision needed: <what, from whom, by when>. Out of scope: <what this summary does not cover>.
Prepared <name, date>. Approved <name, date>. WORKED EXAMPLE
At a real lender, an analyst in credit risk writes this and the head of credit risk signs it. Here Tobechukwu writes and Onyekachi signs, from the lab’s figures.
Target. Bad is 90 or more days past due within 120 days of disbursement, observed to 28 October. At 120 days no loan is immature. 331 are bad, against 368 at 90+ days at the cut-off, because 37 reached 90 days after their window closed.
Sample. 3,645 approved loans of 8,386 applications; the 4,741 others have no outcome. Train: applications 12 January to 31 March, 543 loans, 53 bad (9.8%). Test: 1 April to 27 June, 3,102 loans, 278 bad (9.0%).
Variables. Kept: bureau score (IV 0.573, safer as it rises; 740+ is 3 bad in 150 loans, WoE 1.56; thin files 129 loans, 18.6% bad), KYC tier (0.286), wallet inflow in 60 days (0.122), delinquencies (0.050). Dropped: enquiries (0.130) and history (0.132), not monotone; open loans (0.006), weak. The bureau IV is above 0.5, so I checked the report is dated at application: it is.
Performance. Test AUC 0.678, Gini 0.356, KS 0.292; train AUC 0.728. The bureau score alone gets 0.648. Bad rate by band falls from 17.8% to 3.1% on test.
Limits. 281 of the 331 bad loans are salary advances, so the card mostly learns salary-advance failure. No approved loan scores under 561 on the bureau; 4,070 declined applications since 1 April have no outcome. It could be wrong if the April to June gain is luck: a quarter of shadow outcomes would show it.
Decision. Run beside the old cut-offs for a quarter, deciding nothing. Out of scope: pricing and fairness testing.
Now you
A month later, the credit committee at the same lender asks whether a longer window changes the story. You are the analyst. Onyekachi, head of credit risk, reads your summary and signs it. His decision: whether a 150-day card replaces the 120-day card in the quarter-long shadow run, or neither does. You need not run any code: a colleague reran the lab with a 150-day window and sent you these figures.
- Sample: 2,174 of 3,645 approved loans are old enough; 1,471 are left out; 231 are bad (10.6%).
- Train, 12 January to 31 March: 543 loans, 60 bad (11.0%). Test, 1 April to 31 May: 1,631 loans, 171 bad (10.5%).
- Kept: bureau score (IV 0.621), KYC tier (0.288), wallet inflow (0.121), delinquencies (0.061). Dropped, bad rates zigzag across bins: enquiries (0.062), history (0.084), open loans (0.022).
- Test AUC 0.632, Gini 0.263, KS 0.215; train AUC 0.731. Bureau score alone: 0.606. Bad rate by band on test: 15.7% lowest, 5.1% highest.
- Unchanged: 4,070 declined applications since 1 April with no outcome; no approved loan under 561 on the bureau score.
Say what the shorter sample costs the card.
Self-check
Tobechukwu's card has a test AUC of 0.678 against 0.648 for the bureau score, ranks in order by band, and was built on 53 bad loans. The lender has 3,645 loans and has declined thousands more. Onyekachi must decide how it is used. The sales team wants it to decide all applications from next week, and the board has asked what happens to customers the old rule declined.
- BOOK Credit Scoring and Its Applications, second edition Lyn Thomas, Jonathan Crook and David Edelman, 2017
The standard academic text on consumer credit scoring from SIAM. Read how it defines good and bad and measures a scorecard; skip the later chapters on Basel and survival models until you need them. Read: the chapters on building scorecards and on assessing them.
- BOOK Intelligent Credit Scoring, second edition Naeem Siddiqi, 2017
The practitioner's guide the weight of evidence, information value and points-to-double-the-odds workflow follows. Read the development steps; its software examples are tied to one vendor and you can skip them. Read: the chapters on scorecard development and on validation.
- PAPER Statistical Classification Methods in Consumer Credit Scoring: a Review David Hand and William Henley, 1997
A classic survey of the statistics. Read what it says about applicants who were rejected and have no outcome, which the last section of this chapter relies on. Read: the sections on the problem, on reject inference and on measuring performance.
- PAPER An Information-Theoretic Framework for Credit Risk Modeling 2025
A recent paper that ties the industry's weight of evidence and information value to statistical theory. Read the abstract and the parts on the two measures; this chapter has not checked its other claims. Read: the parts on weight of evidence and information value.
- DOC FCCPC: Digital lending, FCCPC tackles abuses, issues landmark regulations Federal Competition and Consumer Protection Commission, 2025
The regulator's own announcement of the 2025 digital lending regulations. Read it for scope and aims, then read the Regulations themselves for what data a lender may use to score a borrower.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.