Credit default prediction for the Zindi African Credit Scoring Challenge using group-aware validation, feature engineering, CatBoost and LightGBM, with Kenya–Ghana domain shift analysis.
# African Credit Scoring Challenge — Zindi
Machine-learning experiments for the **July Study Jam Series: African Credit Scoring Challenge** on Zindi. The task is to predict whether a borrower will default on a loan, evaluated with **F1 score**.
**Best public leaderboard F1: `0.800904977`**
> This repository documents both the modelling work and the validation/transfer-learning lessons from a difficult cross-country credit-risk problem. The strongest local validation scores did not fully transfer to the leaderboard because the training data is Kenya-only while the test data also includes Ghana.
## Problem
Financial institutions need robust default-risk estimates for both existing borrowers and new applicants. The competition asks for a binary prediction:
- `1` — loan default
- `0` — no default
The metric is **F1 score**, making the precision/recall trade-off important under strong class imbalance.
Competition:
zindi.world
## Approach
The project evolved from a CatBoost baseline into a group-aware, feature-rich modelling pipeline.
### 1. Leakage-aware validation
Borrowers may occur in multiple rows and across multiple loans. I used **`StratifiedGroupKFold` grouped by `customer_id`** so that the same borrower does not appear in both training and validation folds.
### 2. Loan and customer sequence features
Features include:
- repayment ratio and implied interest rate
- lender profit / lender repayment share
- loan duration and calendar features
- customer loan number and total number of loans
- days since previous loan / until next loan
- whether a loan is active at the customer's latest observed loan date
- amount relative to the customer's historical amount profile
- lender- and loan-type profile statistics
### 3. Robust preprocessing
The later LightGBM experiment adds numeric winsorization to reduce the influence of extreme financial values.
### 4. Model families
Experiment …