MSc Data Science dissertation · University of East London · Open source
Loan Default Prediction
Can machine learning help Ugandan microfinance lenders tell defaulters from good borrowers? I rebuilt my dissertation's models as a tested pipeline to find out which of its results really hold.
- Role
- Sole author
- Models
- 3 + baseline
- Real-loan AUC
- ≈ 0.80
- Degree
- MSc, Distinction
The question
Microfinance institutions lend to people the banks leave out. In Uganda, 42% of adults had no formal financial services in 2018. Defaults push lenders to lend cautiously, which shuts out creditworthy borrowers. And traditional credit scoring needs payslips and credit history that people in the informal economy rarely have.
The dissertation asked whether models trained on basic loan and borrower details could support fairer, more consistent lending decisions by smaller microfinance institutions.
Being honest about the data
The data follows the public Kiva loan dataset for Uganda, Kenya, Rwanda and Ghana. But Kiva doesn't record whether a loan was repaid, so the dissertation simulated the default label at about 22%, a rate taken from East African microfinance research.
That means every score on simulated data measures how well a model recovers a label we made up, not how well it predicts real repayment. The rebuild says so up front, and adds a dataset with real outcomes to test against.
How the pipeline works
- Generate loans with a noisy, rule-based risk score (riskier sectors, repayment patterns and loan sizes), or with labels that are pure chance.
- Split 80/20, keeping the default rate the same in both parts.
- Fit every cleaning and encoding step on the training data only, inside a scikit-learn pipeline, so nothing about the test data leaks in.
- Train Logistic Regression, Random Forest and XGBoost, plus a baseline that always predicts "no default".
- Report precision, recall, F1 and ROC-AUC on the test set, with cross-validated AUC alongside.
The live Streamlit app runs the same pipeline on generated data, an uploaded CSV or a real credit dataset. It has a threshold slider, ROC and precision–recall curves, and feature importance.
What the rebuild found
The perfect score didn't hold up
The dissertation reported a perfect Random Forest (1.000 on every measure) and flagged it as suspicious. With realistic noise in the labels, Random Forest scores an AUC of 0.78. A perfect held-out score only happens when the label is an exact function of the inputs, or when it leaks into them.
A built-in check against fooling yourself
On labels that are pure chance, every model falls to an AUC of about 0.5 under cross-validation, as it should. An automated check fails if a model ever learns from random labels, which would mean the pipeline is leaking the answer.
Accuracy was the wrong measure
On simulated data, every model scored 78–81% accuracy. So did the baseline that never predicts a default, and it catches no defaults at all. Recall and AUC are what show whether a model is useful to a lender.
Results on real loan outcomes
The UCI German Credit dataset has 1,000 real loans with observed outcomes (30% bad):
| Model | Recall | ROC-AUC | CV ROC-AUC |
|---|---|---|---|
| Always "no default" | 0.000 | 0.500 | 0.500 |
| Logistic Regression | 0.533 | 0.801 | 0.772 ± 0.055 |
| Random Forest | 0.417 | 0.798 | 0.794 ± 0.044 |
| XGBoost | 0.550 | 0.813 | 0.798 ± 0.037 |
All three models beat the baseline clearly. The gaps between them are smaller than the cross-validation spread, so no model is clearly best.
Before anyone lends on this
The work shows a sound method, not a validated Ugandan credit model. A real deployment would need loan-level repayment records from microfinance institutions, validation on a later time period, calibrated probabilities and a cut-off set by what each kind of error costs. It would also need a fairness audit, since gender is an input, plus human review and a way for applicants to appeal.