Africa credit scoring challenge
README (2).md
# African Credit Scoring Challenge — Zindi World
**Final Public Score:** 0.6740 | **Rank:** 46 | **Submissions:** 12
**Metric:** F1 Score | **Python:** 3.11.15
---
## Problem Statement
Predict whether a borrower will default on a loan using customer and loan data from Kenya (train) and Ghana (test). The cross-country split makes generalization a core challenge — the model must learn patterns that hold across different financial contexts, not just memorize Kenyan borrower behaviour.
---
## Dataset Structure
The raw data has one row per customer-loan-lender triplet. A single loan can be funded by multiple lenders, meaning the same loan ID appears multiple times with different lender IDs. The first preprocessing decision was aggregating to one row per loan using `groupby('tbl_loan_id').agg('first')`, dropping all lender-level columns since lender identity has no bearing on borrower repayment behaviour.
Additional macroeconomic indicators from the Federal Reserve Economic Data (FRED) portal were provided for Kenya, Ghana, and Cote d'Ivoire covering 2001–2023.
---
## Approach
### Preprocessing
- Aggregated from row-per-lender to row-per-loan
- Extracted disbursement and due month, applied cyclic (sine/cosine) encoding to preserve the circular nature of months
- Bucketed rare loan types (below 1% frequency) into an `Other` category
- Engineered `interest_amount` and `interest_burden` (repayment-to-principal ratio)
- Joined FRED macroeconomic indicators (inflation, deposit rate, exchange rate, unemployment) by country and disbursement year
- Handled class imbalance (~98% non-defaulters) using `class_weight='balanced'`
### Validation Strategy
Used `GroupKFold` (5 splits) with `tbl_loan_id` as the group key to prevent validation leakage — ensuring all rows of the same loan stay on the same side of every split.
### Models
- **LightGBM** — primary model, tuned via `RandomizedSearchCV` with `GroupKFold`
- **XGBoost** — secondary model with `scale_pos_ …