The first explanations cited the wrong reasons
An earlier version ranked factors by their raw value, which surfaced large but irrelevant numbers ahead of what actually drove the decision.
Fraud decisioning tuned to what fraud actually costs a bank, not a textbook metric. With an explanation for every decline.
With 492 frauds among 284,807 transactions, a model that never flags anything is 99.8% accurate. Accuracy is the wrong question. The right one is how much fraud you catch at a cost the bank and its customers can live with.
The UK has no equivalent of the US adverse action notice. When an automated system declines a transaction here, the customer is rarely told why in any meaningful way.
The FCA’s Consumer Duty expects communications customers can understand. So every decline this system makes carries a plain-English reason computed for that specific transaction, built into the API rather than bolted on.
Every dataset is versioned, so any model can be traced back to exactly what it learned from.
DVCTrain on the earliest 70%, validate on the next 15%, test on the final 15%. No future data leaks into training.
Out-of-time 70/15/15Optimal binning on the training set only, to find predictors that correlation misses.
IV · 34 → 30 featuresLogistic regression, random forest and XGBoost, trained under identical out-of-time conditions.
MLflow on DagsHubEvery threshold is costed on the validate set against missed fraud and false alarms. The cheapest is frozen before the test set is opened.
Threshold 0.0716A containerised API returns the decision with its reasons; a live dashboard tracks performance and drift.
BentoML · Docker · StreamlitF1 treats a missed fraud and a false alarm as equally costly. They aren’t. On the validate set, the cost threshold (0.0716) caught 12.5 points more fraud than the F1 threshold (0.9311) and cut cost by a third. On the later test window it didn’t hold up; see Results.
Random forest beat XGBoost on test KS and AUPRC. At the real threshold its precision collapsed to 8.1%, against XGBoost’s 48.1%, because its scores weren’t calibrated to the true fraud rate. With 52 test frauds the ranking gaps are within noise; the precision gap is not. Recalibrating random forest is the first untested challenge to this choice.
Random splits let future transactions into training. The test-set fraud rate (0.122%) differed from training (0.193%): a real shift a random split would have hidden.
Fraud invented by interpolation never appears in production. Weighting kept the real distribution: XGBoost’s average score (0.16%) closely matched the true fraud rate (0.131%).
Fraud isn’t linear. IV exposed amount’s U-shaped risk: card testing below €1.19 and account takeover above €237, invisible to correlation.
| Model | KS | AUPRC | F1 | Precision at the business threshold |
|---|---|---|---|---|
| XGBoost · champion | 0.805 | 0.760 | 0.832 | 0.481 |
| Random forest | 0.843 | 0.775 | 0.848 | 0.081 |
| Logistic regression | 0.857 | 0.697 | 0.787 | 0.004 |
How to read this. KS and AUPRC measure ranking: whether fraud tends to score higher than legitimate transactions. Precision at the business threshold measures what happens at the single operating point a bank would deploy. On ranking alone, XGBoost doesn’t win. At the threshold, it is the only usable model: logistic regression flags 31.5% of all transactions, and about 12 of every 13 random forest alerts are false alarms. At 0.0716 on the out-of-time test set (42,722 transactions, 52 frauds), XGBoost made 81 declines: 39 frauds caught and 42 false alarms, or 19 alerts per 10,000 payments.
Validate: 91.1% caught at 52.6% precision. Test: 75.0% caught at 48.1% precision.
Validate: 78.6% caught at 97.8% precision. Test: 73.1% caught at 88.4% precision.
cost = (missed fraud × £150) + (false alarms × £10) → tested at every threshold on validate, then frozen
Stated honestly: cost shown as validate → test. On the later test window the cost-optimal threshold caught one more fraud than the F1 threshold for 37 more false alarms, and cost £220 more. With only 56 validate frauds the cost-optimal point is unstable over time, so a production version would recalibrate it on a rolling window and monitor alert precision alongside KS.
A feature that made the transaction look safer must never appear as a reason it was blocked. That would misrepresent the model’s own reasoning.
V1 to V28 are anonymised PCA components whose real-world meaning is unknown, so the notice calls them “behavioural risk indicators” instead of inventing a story. Only features I engineered are described concretely.
An earlier version ranked factors by their raw value, which surfaced large but irrelevant numbers ahead of what actually drove the decision.
Random forest won on test KS, AUPRC and F1. Applied at the deployment threshold, about 12 of every 13 of its alerts were false alarms.
Four rolling transaction features were engineered, and only one survived feature selection. Without customer IDs, they mixed different people’s histories.
I froze what I had measured, built the production layer around it, and proved the new layer gives the same answers as the old one. On the way, I caught my own system changing the model without anyone deciding it should.
While freezing v1, I found the weekly Airflow DAG had retrained 48 times between June and November 2026 on older libraries. That gave a different model (test KS 0.836 against v1’s 0.805), logged into the v1 experiment with no promotion gate: exactly the “model changes without governance” risk a model-risk team worries about. I paused it, corrected my own README, and made any return to scheduled retraining depend on a promotion gate.
v1 had no gate; “XGBoost” was hard-coded. The new gate judges each model at its own cost-optimal threshold, on validate first and then once on test. At its own threshold, Random Forest had better precision on validate (0.590 against 0.526) but cost £180 more (£1,390 against £1,210). The gate decides on cost, so XGBoost stays, and the result is logged to MLflow either way.
A streaming system that disagrees with the validated batch model is a new, unvalidated model. Tolerances were fixed before any run, and all 42,722 out-of-time test rows were compared: scores within 9.3e-10 and 0 decision flips in all 4 runs, including injected duplicates and late events and a forced crash restored from a checkpoint. The 1,979 rows affected by a deliberately dropped late event are reported separately (0 decision flips) and excluded from the parity claim, not hidden.
The AWS design in Terraform comes to about $25.28 a month, priced from the AWS Price List API. A load balancer alone would add $25.45 a month, and a NAT gateway was also left out. The cost of that choice: no TLS and no zero-downtime deploys, which a production version would add.
| Component | Status | Real result |
|---|---|---|
v1 frozen at tag v1.0-evaluated | done | A hash-checked bundle (models plus validate and test data, about 26 MB). Every CI run recomputes all 181 v1 results exactly, on Windows and Linux. |
| Promotion gate | tested locally | Each model judged at its own cost-optimal threshold, validate first, then once on test. Both challengers lost; logged to MLflow either way. |
| CI · GitHub Actions | passing on GitHub | Lint (new code only), 29 tests, the v1 regression check, a Docker build and smoke test of the API, and a Terraform offline plan. No secrets. Coverage is 25%, stated, not padded. |
| Service monitoring · Prometheus + Grafana | tested locally | p95 38 ms at 50 requests/s; one worker saturates at about 80/s. Model + SHAP: p50 8.2 ms, p95 18 ms, so most latency is HTTP overhead. 0 server errors; bad input now returns 400, where v1 returned 500. |
| Streaming · Kafka + PyFlink | tested locally | 992 events/s against a 1,000/s target (p95 829 ms); about 2,500/s sustained at 3× overload. Exact parity with v1 batch in all 4 runs. |
| AWS via Terraform · ECR, ECS Fargate, S3, IAM with GitHub OIDC | designed only, not deployed | Validate and an offline plan pass (25 resources). About $25.28 a month if deployed. No AWS account exists, and terraform apply has never been run. |
| Helm on kind | not done | Skipped: it doesn’t fit in the laptop’s Docker memory and would add no new evidence. |

Not proven, said plainly: the throughput figures come from one laptop running every component at once. The Terraform plan proves the configuration, not the IAM permissions. And with 52 test frauds, one case moves recall by 1.9 points. Every decision is in the decision log.
Decision, SHAP reasons and the exact customer notice, plus the threshold trade-off, champion choice and drift. Nothing calls a model.
Change a transaction’s features and watch the decision flip. May take about 30 seconds to wake.
Metrics per model per dataset, thresholds and champion–challenger comparisons.
Airflow DAGs, BentoML service, Docker setup and the reasoning behind every decision.