AI-powered credit risk prediction system for Kenya’s informal economy using alternative financial indicators and machine learning.
# loan-default-kenya
AI-powered credit risk prediction system for Kenya’s informal economy using alternative financial indicators and machine learning.
# Predicting Loan Default in Kenya's Informal Economy
## Overview
Binary classification model for a Nairobi-based MFI, predicting loan default risk using alternative data — mobile money behaviour, group lending membership, and repayment track record.
## Files
- `loan_default_kenya.ipynb` — Full Jupyter notebook (all analysis + policy note)
- `informal_loan_default.csv` — Dataset (place in the same folder as the notebook)
## How to Run
### 1. Install dependencies
```bash
pip install numpy pandas matplotlib seaborn scikit-learn jupyter
```
### 2. Launch
```bash
jupyter notebook loan_default_kenya.ipynb
```
### 3. Run all cells
**Kernel → Restart & Run All**
Make sure `informal_loan_default.csv` is in the **same folder** as the notebook.
---
## Notebook Structure
| Section | Content |
|---------|---------|
| 0 | Imports & setup |
| 1 | Load `informal_loan_default.csv` |
| 2 | EDA — distributions, default rates by group |
| 3 | Missing value analysis (`mpesa_avg_balance_ksh`) — MNAR pattern + imputation decision |
| 4 | Feature engineering (4 new features with justification) |
| 5 | Preprocessing pipeline (median imputation + StandardScaler) |
| 6 | Model training: Logistic Regression, Random Forest, Gradient Boosting |
| 7 | Evaluation — ROC-AUC, Gini, confusion matrix, feature importance |
| 8 | Three-tier decision system: Approve / Human Review / Decline |
| 9 | Policy note for lending manager |
## Key Design Decisions
| Decision | Choice | Reason |
|----------|--------|--------|
| Missing value imputation | Median (not mean) | `mpesa_avg_balance_ksh` is right-skewed; mean would overestimate |
| MNAR handling | Retain `balance_missing` flag | Small but real default-rate difference carries signal |
| Primary metric | Recall | Missed defaults = principal loss; higher cost than false positives |
| Decision th …