Context

Lenders in West and East Africa score customers who often have no bureau history. The signal sits in mobile money, POS and transfer activity, spread across XOF, NGN and KES. All data here is synthetic, produced by a seeded generator with thin-file customers, dormant accounts and about 2% dirty rows.

Problem

A score is only as good as the features behind it. Two failures matter most: a batch that silently drops customers, and an upstream change that shifts every score overnight without anyone noticing.

Technical choices

  • Two repos, one contract. credit-scoring-dbt owns the credit_features table; airflow-batch-credit-scoring only reads it. Each side can change without breaking the other.
  • Staging does the dirty work. Failed and reversed transactions are filtered, amounts are normalized to USD, so the mart only computes features: RFM, 30/7-day and 24-hour velocity, mobile and international ratios, spend to income.
  • Chunked scoring. list_chunks splits the base, score_chunk runs as dynamic task mapping with capped parallelism, then one atomic publish.
  • The model is code. The logistic coefficients live in the repo and change through a pull request. model_version is stored next to every score.
  • Drift gate. The Population Stability Index compares today's scores with yesterday's. Above 0.25 the run fails and nothing is published.

Tests

  • dbt tests on uniqueness and relationships, plus singular tests: every ratio between 0 and 1, every customer present in the feature table.
  • pytest on the scoring side: score bounds, monotonicity (riskier behavior gives a lower score), band mapping, PSI on identical, slightly shifted and drifted distributions, first run with an empty baseline, DAG structure.
  • Both repos run their suite in GitHub Actions.

Results

A nightly run that either publishes a full, versioned set of scores or stops before anything reaches a lending decision.