← All work(02) / (04) · Case study

Sentinel credit.

Credit decisioning for thin-file BNPL customers that bureaus can’t see, built on a synthetic portfolio I generated. Modelled, explained and governed. Built to pass a model risk review.

RoleData Scientist / ML Engineer
StackPython · PostgreSQL · XGBoost · SHAP · MLflow · Airflow · FastAPI · ONNX · v2: PyTorch · Kafka · PyFlink · Spark · Docker
DataSynthetic, from a simulator I built · 50k customers · 174k transactions · 484k repayments
StatusChampion v1.1 live · loop runs end to end locally · public demo on GitHub Pages · v2 tested locally · AWS designed and priced, not built
0.56Gini, stable out-of-time · 0.5618 stratified → 0.5611 out-of-time
41,604Customers re-scored: 0 decisions changed between browser and Python models
79%Overlap I found in my own drift monitor’s comparison data, and removed
35Engineering decisions logged with their evidence
01 · The problem

Why it needs to exist

BNPL lenders serve people a credit bureau barely knows. A model for them has to do more than score well: it has to survive a model risk review, explain every decision and notice when the world moves.

Customers with thin credit files are hard to assess on conventional signals, which makes governance, explainability and responsible deployment matter more, not less.

So the project treats governance, monitoring, auditability and deployment as first-class engineering problems, with every major decision linked to published research or regulatory guidance, including PRA SS1/23.

02 · The data

I built the dataset from scratch

No public dataset represented UK BNPL customers, so I built one. A simulator where default isn’t assigned to anyone in advance: it emerges from how each customer actually repays.

50,000Customers
174kTransactions
484kRepayments
8/8 · 2/2Fidelity 8/8 · privacy 2/2 · utility pass
Hazard-based default

Default emerges from behaviour

Each customer follows a repayment hazard process and reaches the CRR/EBA 90-days-past-due definition through actual delinquency. That keeps repayment history a genuine predictive signal, not a by-product of the label.

Traceable values

Every value has a stated origin

Generation separates published evidence, calibrated values and documented engineering assumptions, so the source and justification of every generated number stays explicit.

Proven fit for purpose

Validated like a regulator would ask

Checked for fidelity, utility and privacy under the FCA, ICO and Alan Turing Institute synthetic-data framework. Generator-only variables stay in the raw layer for audit and never reach the model.

Lesson. Generating synthetic data is easier than proving it is fit for purpose. Loading it into PostgreSQL with real constraints exposed an identifier collision that Python validation had passed.

03 · How it works

A closed credit-risk loop

  1. 01

    Generate the customers

    My own simulator creates customers, orders and repayments, with default emerging from a repayment hazard process.

    Built from scratch · 50k customers
  2. 02

    Prove the data is fit

    Validated on fidelity, utility and privacy, following the FCA, ICO and Alan Turing Institute framework.

    Fidelity 8/8 · Privacy 2/2
  3. 03

    Engineer features in SQL

    A constrained PostgreSQL schema and a 64-column feature store, built close to the data.

    PostgreSQL · 13 model features
  4. 04

    Train and calibrate

    Three models benchmarked; a Platt-calibrated XGBoost champion with a cutoff set as review-capacity policy.

    MLflow · cutoff 0.0657
  5. 05

    Explain the decision

    The applicant sees the outcome, the reasons in their own figures and what could change it; a risk officer gets a review flag.

    SHAP · plain English
  6. 06

    Monitor and govern

    PSI drift checks under Airflow, champion–challenger in the MLflow registry, and an approval gate with typed human confirmation.

    Airflow · Model Registry
Honest noteThe whole loop runs end to end on a local stack (PostgreSQL, Airflow and the API). The public demos are a static site on GitHub Pages and a Streamlit dashboard in snapshot mode. Cloud deployment on AWS is designed and priced, not built.
04 · Decisions

What I chose, and what I rejected

D27

Remove a leaking feature from the live modelover keeping the higher Gini

pct_late_payments partly encoded the outcome. Removing it cost −0.0038 Gini, with a 95% CI of [−0.0148, +0.0079]: not distinguishable from zero. It was promoted through an evidence-bound validity override and a typed human confirmation.

D10

Default that emerges from repayment behaviourover labels assigned in advance

A label set before the behaviour that should predict it produces features that can’t be trusted, however plausible the values look.

D19

A cutoff set by review capacityover a default 0.5 or F1

The threshold is a policy parameter of the decision engine, chosen on training-only out-of-fold predictions so that 15% of applications go to review. This synthetic lender has no loss or review-cost figures to price errors on, so the cutoff is tied to workload, and the 15% is a stated assumption. Where error costs can be estimated, pricing the threshold on them is the stronger method.

D29

Score in the visitor’s browser, gated on parityover hosting a public API

No server, no database, no endpoint exposed to strangers. Nothing was built on the converted model until it matched the champion: 41,604 customers, max difference 5.96e-08, zero decision flips.

D12

Leave segment thresholds to governanceover quietly tuning a cutoff per segment

Segment-aware thresholds are a Consumer Duty and governance decision, not a modelling one. The trade-off is published in the demo’s cutoff simulator instead.

05 · Results

Champion v1.1, held out

MetricStratifiedOut-of-time
Gini0.56180.5611
AUC0.78090.7806
KS0.47120.4390
Sent to review at cutoff15.9%11.9%
Defaults caught (recall)57.96%40.32%
Precision9.90%8.65%
Bad rate among those not reviewed1.36%1.73%

How to read this. 41,604 customers with an observed outcome; default rate 2.72%. Precision is judged against that base rate, not against 100%. The riskiest 10% of customers hold 39% of all defaults (lift 3.93×). Recall drops out of time, so the cutoff is a trade-off a lender would revisit.

0.5618XGBoost · champion
0.5486Decision tree
0.4896Logistic regression
0.5618 → 0.5611

Gini holds out of time

Discrimination barely moves between the stratified test set and later-originating customers, after the leaking feature was removed, even though removing it cost score.

100%

Known limitation: established-file defaulters

At the cutoff, every defaulter with an established credit file is scored below it, on both splits, while thin-file customers carry most false alarms. The model still ranks risk within that segment; one shared probability scale is the problem. Segment treatment is an open governance decision.

Score an application yourself

The governed champion runs entirely in your browser on synthetic data. Nothing you type leaves the page, and the site re-checks itself against the Python model before every deploy.

Open the live demo →
06 · What went wrong

Found in my own audit

Leakage

The live model was reading the outcome

The October audit found pct_late_payments counted arrears pay-offs, and post-default instalments sat in its denominator.

What changedRemoved, re-approved through governance as v1.1, cutoff recalibrated. The v1 package is kept for rollback.
Monitoring

A drift monitor comparing data with itself

79.3% of the comparison population was also in the training reference, which pulls PSI towards zero. The logged runs were fixed snapshots, not a trend.

What changedOverlap excluded: the comparison is now the 1,003 later customers the model never saw, and several PSI values rose. An origination-cohort view was added.
Data integrity

An identifier collision Python missed

Validation in notebooks passed. Loading into PostgreSQL with real constraints exposed a collision in the identifiers.

What changedThe identifier strategy was redesigned, and database-level integrity constraints became part of the design.
07 · Version 2

Three times the evidence said no

In v2 the evidence said no three times, and each time I reported it rather than shipping the newer thing. A neural challenger lost, a streaming target was missed, and Spark lost to PostgreSQL at 2M customers. The tools were the test; the decisions are the result.

V2-01

Prove v1 is untouched before building on itover asserting “nothing changed”

v1 was frozen at a Git tag and fingerprinted: model files, feature definitions, database row counts and columns, all 103 MLflow runs. CI checks it on every push. v2 writes only to its own schemas; the API, dashboard and Power BI still read v1.

V2-02

Keep XGBoost: the PyTorch challenger lostover promoting the newer model

It passed the Approval Gate’s integrity checks, but passing the gate is not winning. Stratified Gini 0.5329 against 0.5618, a 95% CI excluding zero. Out of time 0.5700 against 0.5611, a CI including zero: noise, not a win. It also misses every established-file defaulter, like the champion. More model complexity does not fix a problem in the data.

V2-03

Report the streaming target as missedover quietly lowering it

Kafka and PyFlink rebuilt the features live and matched the v1 feature store for 50,000 of 50,000 customers. I redesigned when the measurements showed my first design capped at about 340 events/s. The goal was 1,000/s; one laptop sustained about 360/s, written up as not achieved. Scores run in shadow mode: recorded, never used to decide, until the path is validated.

V2-04

Exact features first, then recommend against Sparkover adopting the tool built for scale

Every engine had to reproduce the feature store exactly (0 of 126 million values different at 2M customers) before its timings counted. At 2M, PostgreSQL took 211 s, pandas 302 s, Spark 354 s. Spark scaled best but did not pay off on one machine. No retraining on the new data: that needs its own feature and cutoff decisions.

Next

Price the cloud before building itover deploying and seeing the bill

The API on AWS ECS Fargate in London, IP-restricted, torn down the same day. Priced from AWS’s published rates at about $0.08 an hour, and paused on budget. Designed only, not deployed.

Status. All v2 work is tested locally on synthetic data or a simulated replay, with every number from a real run. Failed runs are kept in the v2 decision log.

08 · Scope

What this does and doesn’t prove

It does show

  • A governed champion that holds its Gini out of time
  • A public demo proven identical to the Python model
  • Drift monitoring that can actually detect change
  • A challenger that lost, and was not promoted
  • Every major decision logged with its evidence

It doesn’t show

  • Performance on real customers: all data is synthetic
  • Cloud operation: AWS is designed and priced, not built
  • Production throughput: v2 streaming and scale ran on one laptop
  • Who approved a promotion: approver identity isn’t recorded yet
  • Regulatory approval: research informed it, nobody certified it
09 · Build log

Written up on LinkedIn

Model governance

What if the challenger looks better while drift is active?

LinkedIn↗
Model governance

The leak I found in my own live credit model

Coming soon