← All projects
Completed Personal Project Nov 2026

Credit Risk ML Platform

Predicts the probability that a consumer loan defaults, then turns it into decisions: risk grades, approval cut-offs, collections priorities and drift alerts. The model, API and dashboard below are live.

Test AUC
0.769
Gini
0.537
Lift in the riskiest 10%
3.5x
Loans modelled
307,511
PythonLightGBMscikit-learnSHAPMLflowFastAPIStreamlitDockerGitHub Actions

Overview

What the project does, what each dashboard is for, the data behind it, how the model performed, and the regulatory context.

Open full screen ↗

About this page

An end-to-end credit risk platform, built the way a bank would run one. A machine-learning model predicts each applicant's probability of default (PD): the chance they will struggle to repay. The platform turns that into risk grades, credit decisions, approval and collections strategies, and drift alerts, and explains every score.

Behind the dashboards: a LightGBM champion model trained on 196,806 loans and tested on 61,503 it never saw, managed in MLflow, served by a FastAPI scoring service in Docker, and checked by automated tests on every change.

Live demo on free hosting: after a quiet spell the dashboard and API take up to a minute to wake up (choose “Yes, get this app back up” if asked). It scores 5,000 simulated applications, because the Home Credit data can't be redistributed; the model does somewhat less well on them (AUC about 0.70) than on the real data (0.769). Amounts are in the lender's undisclosed local currency.

What each dashboard is for

TabQuestion it answersTypically used by
PortfolioHow risky is the book, and where is the risk concentrated?Risk managers
Customer ScoringShould we lend to this applicant, and why?Credit officers
Model PerformanceIs the model accurate, and can its PDs be trusted?Model validators
Strategy SimulatorWhere should the approval cut-off be, and whom should collections call first?Credit strategy and collections teams
Model MonitoringAre applicants changing in a way that breaks the model?Model risk and MLOps teams

About the data

The model was built on the Home Credit Default Risk data: 307,511 consumer loans with an 8.07% default rate. The competition's terms don't allow the data to be redistributed, so the live demo scores 5,000 simulated applications instead. They have the real test set's risk mix, but their outcomes are deliberately noisier. The model still performs well on them (AUC about 0.70, against 0.769 on the real data), but less well than on its own test set, as models do on new data. No real loan is published.

Currency: the data doesn't say. Amounts are in the lender's local currency, and even the credit bureau's currency field is anonymised as "currency 1" to "currency 4". The dashboards therefore show amounts as plain numbers, not rand or dollars.

How the model performed on the real data

61,503 held-out loans, shared here only as summary figures.

MeasureResultWhat it means
Ranking power (AUC / Gini)0.769 / 0.537Strong for an application scorecard (typical AUC: 0.70–0.80).
Separation (KS)0.400Good separation of defaulters from non-defaulters.
Calibration8.00% predicted vs 8.07% actualPDs can be taken at face value.
Riskiest 10% of applicants35.5% of all defaults3.5x better than random.
Riskiest 20% of applicants54% of all defaults2.7x better than random.
Riskiest vs safest tenth28.6% vs 1.1% default rateRisk falls steadily from decile to decile.
Validation vs test AUC0.763 vs 0.769Holds up on unseen data: no over-fitting.
Challenger models (test AUC)Logistic regression 0.751, random forest 0.747LightGBM was best on validation, so it became champion.
Decisions (approve < 10% PD, decline ≥ 20%)Approve 74.8%, refer 16.8%, decline 8.4%Declined applicants default 7x as often as approved ones (30.3% vs 4.2%).

Predicted vs actual default rate by risk grade

GradeShare of loansPredicted PDActual default rate
A (PD < 2%)15.0%1.4%1.3%
B (2–5%)34.1%3.4%3.3%
C (5–10%)25.7%7.1%7.3%
D (10–20%)16.8%13.9%14.0%
E (20% or more)8.4%29.8%30.3%

Predicted and actual rates agree within half a percentage point in every grade, so the grades can be used for pricing and limits.

Regulation: South Africa vs the United States

Credit default models are regulated differently in the two countries. Neither prescribes an algorithm: both expect models to be validated, governed and explainable. They differ in who approves the models and what they are used for.

South AfricaUnited States
RegulatorsPrudential Authority (South African Reserve Bank); National Credit Regulator for consumer lending.Federal Reserve, OCC and FDIC; CFPB for consumer lending.
PD models for capitalBasel III. Banks use standardised rules or internal (IRB) models approved by the Prudential Authority; the large banks use IRB.Internal models only at the largest banks; most use standardised rules. A 2023 proposal would replace internal credit models with standardised rules.
Loss provisionsIFRS 9 expected credit loss (12-month or lifetime).CECL: lifetime expected credit loss.
Model governanceBasel IRB minimum standards: independent validation, data history and supervisory approval of material changes.SR 11-7 / OCC 2011-12 model risk guidance: sound development, independent validation and governance.
Customer protectionNational Credit Act: affordability checks, no reckless lending. POPIA restricts credit decisions based solely on automated processing.ECOA / Regulation B: specific reasons for every decline, even from complex models. Fair-lending rules ban discriminatory outcomes.
Flexibility in model typeLower for capital models: they must be approved, stable and explainable, so logistic-regression scorecards dominate. Machine learning is used more for IFRS 9, decisioning and challenger models.Higher: machine learning is common in underwriting, provided it is validated and can give specific decline reasons.

A short, high-level summary, not legal advice. This project follows these expectations (hold-out validation, reason codes, gender excluded) but hasn't been through any regulatory approval.

What the numbers and charts mean

Shown on the pageWhat it meansHow to read it
Champion modelModel version in production (v2, LightGBM).Replaced only by a model that beats it on hold-out checks.
Test AUCChance a defaulter gets a higher PD than a non-defaulter.0.5 is random and 1.0 is perfect. Higher is better.
Gini2 × AUC − 1, the form banks report.0 is random and 1 is perfect.
KSLargest gap between the score distributions of defaulters and non-defaulters.Above 0.40 is good.
PortfolioApplications scored on the other tabs.5,000 simulated applications in the demo.