Credit risk is the chance that a borrower won't pay back their loan. If you lend your friend $20 and they never pay you back, you've experienced credit risk.
Banks face this every day. They lend money to millions of people and businesses. To survive, they must carefully estimate who's likely to repay and who's likely to default β before they hand over the money. Machine learning helps them do exactly that.
Every credit risk model boils down to three questions:
| Term | Question | Example |
|---|---|---|
| PD β Probability of Default | How likely is this borrower to default? | 5% chance |
| LGD β Loss Given Default | If they default, how much will I lose? | 60% of the loan |
| EAD β Exposure at Default | How much money is at risk at the moment of default? | $10,000 |
Multiply them together: expected loss = PD Γ LGD Γ EAD. That's the money a bank expects to lose on average. Our ML models here focus mainly on PD.
For decades, banks built credit scores with logistic regression β a classic ML model that outputs a probability between 0 and 1. Perfect for "what's the chance of default?"
Logistic regression becomes a scorecard: each borrower gets points for their income, credit history, age, etc. The higher the score, the lower the risk. These scorecards are transparent, explainable, and often required by regulators.
Gradient boosting (XGBoost, LightGBM) often outperforms logistic regression on real credit data. It automatically captures interactions and nonβlinear patterns that a simple scorecard misses.
The tradeβoff? It's less transparent. Banks use it carefully, often with SHAP explanations to justify individual decisions (explaining why someone got rejected is legally required in many countries).
Here's the challenge: most people pay back their loans! Defaults might be only 2β5% of your data. If you train a model on that, it could just say "everyone will pay back" and be 95% accurate β but useless.
Solutions: class weighting, oversampling the minority class (SMOTE), undersampling the majority, and evaluating with metrics designed for imbalance β like recall, AUC, and precision instead of plain accuracy.
Banks can't just build a model and use it. Regulators under Basel II / III require strict validation. The model must be tested on outβofβtime data, not just outβofβsample data.
Validation checks include: discrimination (does the model rank risky borrowers lower?), calibration (does 5% predicted PD really mean 5% defaults in real life?), stability (has the model drifted?), and documentation (can a regulator understand it?). Model risk is real risk.
Here's a sneaky problem: banks only lend to people they already approved. So they only have repayment data for people they accepted. What about the people they rejected? They might have been great payers β but they never got the chance!
Reject inference is a family of techniques to estimate what would have happened to the rejected applicants. Without it, your model keeps making the same mistakes as the old model. It's a fascinating example of how data reflects decisions, not just reality.
Design a mini scorecard: Imagine five features (income, age, existing debt, employment years, previous defaults). Give each feature a point value. Score three imaginary applicants. Which one would you lend to?
Expected loss calculation: A borrower has PD = 4%, LGD = 50%, EAD = $10,000. Calculate expected loss. Then double the PD β how much does expected loss change? Notice how sensitive it is.
Imbalance experiment: Imagine a dataset of 1,000 borrowers where 950 repay and 50 default. A lazy model predicts "everyone repays" β what's its accuracy? What's its recall on defaults? Explain why accuracy is misleading here.
Scorecard walkthrough: Write out the logic of a simple scoring rule in plain English: "If income > $50k AND age > 25 AND no defaults, score += 20." Add 4 more rules. Then try scoring three imaginary applicants by hand.
Fairness check: Imagine your model rejects 40% of applicants from Group A but only 15% from Group B. Is that fair? Write one sentence about why historical data might create this pattern and what you'd investigate.
Reject inference puzzle: A bank rejected 100 people. Later, a competitor lends them money β and 90 pay back fine. What does this tell you about the bank's original model? Write a two-sentence explanation.
By the end of this module, you'll be able to: explain PD, LGD, and EAD, build a basic credit scorecard, handle imbalanced default data, recognize the need for model validation, and think critically about fairness and reject inference.