Mpesa data useful for credit risk modelling
# Kenya M-Pesa Synthetic Credit Dataset — Pipeline
End-to-end pipeline for generating, quality-optimising, and publishing
a synthetic M-Pesa credit scoring dataset for the Kenyan context.
## Architecture
```
generate.py Simulate synthetic users from FinAccess 2021 priors
↓
data/transactions_raw.parquet (raw transaction log)
data/features_labels.parquet (engineered features + default label)
↓
adapt.py Adaption Labs quality optimisation + evaluation
↓
data/features_labels_adapted.parquet (quality-graded output)
↓
publish.py Hugging Face upload with dataset card + Croissant metadata
```
## Setup
```bash
pip install -r requirements.txt
export ADAPTION_API_KEY="pt_live_..." # from
adaptionlabs.ai
export HF_TOKEN="hf_..." # from
huggingface.co
export HF_REPO_ID="smainye/kenya-mpesa-credit-synthetic"
```
## Run
```bash
# Full pipeline (5,000 users)
python pipeline.py
# Larger dataset
python pipeline.py --n-users 50000
# Estimate Adaption cost only (no charges)
python pipeline.py --dry-run
# Generate + publish, skip Adaption
python pipeline.py --skip-adapt
# Generate + adapt only, no HF upload
python pipeline.py --skip-publish
```
## Files
| File | Purpose |
|---|---|
| `generate.py` | Persona definitions, transaction simulation, feature engineering, label assignment |
| `adapt.py` | Adaption Labs SDK integration — upload, run, evaluate, download |
| `publish.py` | Hugging Face upload, dataset card, Croissant metadata |
| `pipeline.py` | Orchestrator |
| `requirements.txt` | Python dependencies |
## Persona archetypes (FinAccess 2024 priors)
| Persona | Pop. share | Txn/week | Base default |
|---|---|---|---|
| urban_salaried | 22% | 18 | 9% |
| informal_trader | 27% | 28 | 24% |
| boda_worker | 14% | 42 | 32% |
| rural_smallholder | 24% | 7 | 22% |
| remittance_dependent | 13% | 10 | 22% |
Overall dataset default rate targets ~16.6%, anchored to F …