Credit scoring for M-Pesa, SACCO, and bank lending channels. The system combines channel-specific feature engineering, a calibrated ML model, scorecard conversion, and deterministic policy rules — the same layered pattern used in mature fintech and banking stacks.
# East Africa Credit Scoring Engine
An **unbanked-first** credit scoring platform for East Africa. Most applicants have no traditional bank account — scoring relies on **M-Pesa**, **phone data** (SMS, call log, device tech), and **statements**, with **bank**, **SACCO**, and **CRB** data used when available.
It combines channel-specific feature engineering, a calibrated ML model, scorecard conversion (300–850), deterministic policy rules, **SHAP explainability**, loan limit assignment, and a **FastAPI REST service** with regulatory audit trails.
## Platform at a glance
| Capability | Status | Entry point |
|------------|--------|-------------|
| Multi-channel scoring (unbanked / M-Pesa / SACCO / bank / mobile lender) | ✅ | `score.py`, `/score` |
| Loan limit assignment (increase / decrease / maintain) | ✅ | `src/lending/limit_engine.py` |
| Borrowing & repayment history (all channels) | ✅ | `lending_history` in API |
| Unbanked-first scoring (`channel: unbanked`) | ✅ | M-Pesa + phone; bank optional |
| Optional bank / SACCO / CRB enrichment | ✅ | `data_sources` flags |
| Phone tech (OS, RAM, tier, network) | ✅ | `phone_data.device` |
| Phone data (SMS, call log, contacts, apps) | ✅ | `phone_data`, `src/data/phone_data.py` |
| ML training + evaluation (AUC, Gini, KS) | ✅ | `train.py` |
| Calibrated probability of default (PD) | ✅ | `src/ml/trainer.py` |
| Scorecard mapping (PDO methodology) | ✅ | `src/ml/scorer.py` |
| Policy engine (CRB, DTI, channel rules) | ✅ | `src/policy/engine.py` |
| SHAP feature explainability | ✅ | `src/ml/explainability.py` |
| Regulatory audit trail (JSON) | ✅ | `assets/audit_trails/` |
| FastAPI REST service | ✅ | `serve.py` → port 8000 |
| OpenAPI / Swagger docs | ✅ | `/docs` |
| Synthetic training data (no PII) | ✅ | `src/data/synthetic.py` |
## Table of contents
- Install
- Verify it works
- How to use this package
- Supported channels
- Data sources
- Architecture
- End-to-end workflow
- Project structure
- Training (`train.py`) …