Foundations to Frontier
Tests
N. MLOps and AI Systems Engineering › N5 ML System Design

ML System Case Studies

Case studies show how the ideas of this section combine in real systems, where most of the value often comes from decisions around the model rather than the model itself. The exercises follow a card-fraud detection system through its first 90 days: rare positives, money-weighted errors, chargeback labels that arrive weeks late, fraudsters who change tactics, and a review team with limited capacity. Five successive design decisions are measured in dollars. Practice problems are short case studies from other domains: onboard cloud screening for a satellite with a limited downlink, predictive maintenance with noisy sensors, a medical triage model moved to a hospital with a different prevalence, click prediction that sets prices in ad auctions, and a postmortem of a training–serving skew bug.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Learning from other people’s systems

Engineers learn bridge design from bridges that stood and bridges that fell. ML systems are no different: the same few lessons recur across fraud detection, satellites, factories, hospitals and ad auctions. The right metric is the money or harm at stake, not accuracy; labels arrive late; the world changes; humans and fallbacks are part of the system; and the inputs the model actually receives must be watched.

🎮 MLOps lab
threshold 0.5, never retrained
$178,642 · last 30 days $65,412
expected-loss rule, never retrained
$116,617 · last 30 days $50,762
+ weekly retraining, labels 30 days late
$107,766 · last 30 days $43,109
+ labels 7 days late
$99,084 · last 30 days $37,428
+ 100 analyst reviews a day
$77,863 · last 30 days $29,121

Ninety days, 5,000 transactions a day, 0.5% fraud, tactics drifting. Accuracy at threshold 0.5 is 0.995, barely above blocking nothing; deciding by expected money lost, retraining with fresher labels and reviewing the riskiest cases cut losses from $178,642 to $77,863.

Why engineers care

In Exercise 2, a fraud model with 99.5% accuracy lost $178,642 in 90 days; the same data with a cost-based decision rule, retraining on fresher labels and 100 analyst reviews a day lost $77,863.

📝 Quick check (Level 0)
0/3 answered
  1. 1. For rare fraud, a model with 99.5% accuracy…
  2. 2. Chargeback labels for fraud arrive…
  3. 3. Case studies show that much of a system's value comes from…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Cost-sensitive decisions: act when the expected cost of not acting exceeds the expected cost of acting, for example block a transaction when p·amount exceeds (1 − p)·friction.
  • Class imbalance: with 0.5% positives, accuracy is dominated by negatives; use precision, recall and money-weighted metrics.
  • Label delay: fraud labels come from chargebacks weeks later; retraining uses data at least as old as the delay.
  • Human in the loop: analysts review a limited number of the riskiest cases.
  • Prior shift: a change in the base rate between training and deployment; correct calibrated logits by log(odds_new / odds_old).
  • Calibration: predicted probabilities that match observed frequencies, needed whenever predictions set prices or thresholds.
  • Training–serving skew: features computed differently in training and serving; caught by logging and monitoring served features.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Block a transaction when…
  2. 2. A prior-shift correction adds to the logit…
  3. 3. Training–serving skew means…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

A fraud system after launch

Exercise 1.

  • Transactions with 6 features and a log-normal amount (median $40); fraud is 0.5% of transactions and favours larger amounts.
  • Over 120 days the fraud pattern rotates from one feature to another (new tactics).
  • Logistic regression fitted by Newton’s method on 28 days of labelled data.
  • Costs: an unblocked fraud loses its amount; a blocked legitimate transaction costs $5 of customer friction; an analyst review costs $2.

Practice.

  • Write down the cost of each error and decide by expected cost, not by accuracy.
  • Get labels faster where possible, and retrain on the freshest labelled window.
  • Use human review for the cases where the expected loss is highest.
  • Check calibration and base rates whenever the deployment population differs from the training one.
  • Log the features the model received and monitor them, not only the scores and outcomes.
p = model.predict_proba(txn)
expected_fraud = p * txn.amount
expected_friction = (1 - p) * FRICTION
if txn in review_queue.top(100, key=expected_fraud):
    decision = analyst(txn)
else:
    decision = "block" if expected_fraud > expected_friction else "allow"
🐍 Exercise 1: fraud, accuracy and money
Simulate rare, amount-dependent fraud, fit logistic regression, and compare blocking by probability with blocking by expected money lost.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Blocking by expected loss compared with probability above 0.5…
  2. 2. Faster labels helped because…
  3. 3. Analyst review is best spent on…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Bayes decisions. With probability p of fraud, blocking costs (1 − p)·f in expected friction and allowing costs p·a in expected loss; blocking is right when p·a > (1 − p)·f, that is p > f/(a + f). The threshold therefore depends on the amount: $5/($40 + $5) ≈ 0.11 for a $40 purchase, 0.005 for a $1,000 one. A single probability threshold such as 0.5 ignores the amounts and blocks almost nothing.

Accuracy under imbalance. With 0.5% positives, a classifier that never flags anything is 99.5% accurate; accuracy differences between useful and useless models live in the third decimal. Money-weighted cost, precision at a review budget and recall of fraud dollars are the measures that matter.

Prior shift. If p(x | y) is the same at two sites and only the prior changes from π to π′, Bayes’ rule gives logit p′(y | x) = logit p(y | x) + log(π′/(1 − π′)) − log(π/(1 − π)). A calibrated model can be moved by adding this constant; without it, predicted risks are inflated where the disease is rarer, and positive predictive value falls.

Monitoring the right signal. A bug that changes one input for part of the traffic shifts that input’s distribution sharply, but the score distribution only a little, because the score mixes many inputs, and outcomes respond slowly and noisily. Input monitors catch such bugs first.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The block threshold for a $40 purchase with $5 friction is about…
  2. 2. Under prior shift, a calibrated model is corrected by…
  3. 3. A skew bug in one input shows first in…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How much do the decision rule, retraining, label delay and human review each change the money lost by a fraud system in its first 90 days?

History.

  • Credit-card fraud detection was one of the first large neural-network deployments (for example the Falcon system, 1992) and remains a classic of cost-sensitive learning.
  • C. Elkan (2001), “The foundations of cost-sensitive learning,” set out decision thresholds from cost matrices.
  • A. Dal Pozzolo and colleagues (2015, 2018) studied fraud detection with delayed and partially verified labels and concept drift.
  • M. Saerens, P. Latinne and C. Decaestecker (2002) showed how to adjust classifier outputs to new prior probabilities.
  • Postmortems of ML incidents, such as those collected by Google’s ML engineering practice (E. Breck and colleagues, 2017, “The ML test score”) and the AI Incident Database (2020), made training–serving skew a named failure mode.

Exercise 2.

  • 90 days after launch, 5,000 transactions a day; the fraud pattern drifts; every model is first trained on the 28 days before launch.
  • Policies: block when probability is above 0.5; block by expected loss; expected loss with weekly retraining on the latest 28 labelled days when labels are 30 days late; the same with labels 7 days late; and that plus 100 analyst reviews a day of the highest expected losses.

Seed 0:

policy total loss loss in the last 30 days retrains
threshold 0.5, never retrained $178,642 $65,412 0
expected-loss rule, never retrained $116,617 $50,762 0
+ weekly retraining, labels 30 days late $107,766 $43,109 12
+ labels 7 days late $99,084 $37,428 12
+ 100 analyst reviews a day $77,863 $29,121 12

Seeds 1 and 2, in the same order: $202,050, $127,627, $114,305, $106,465, $86,128; and $185,818, $120,472, $110,092, $100,395, $80,346.

Findings.

  • The decision rule was the largest single gain, about 35% of the loss, with no change to the model.
  • Retraining recovered 8 to 10% more, and faster labels 7 to 9% more again: the drifting pattern rewards fresh data.
  • One hundred reviews a day (costing $200 a day, included) cut the remaining loss by about a fifth in every seed.
🐍 Exercise 2 (research): how much do the decision rule, retraining, label delay and human review each change the money lost by a fraud system in its first 90 days?
Follow a fraud system for 90 days and measure, in dollars, the effect of the decision rule, retraining, label delay and human review.

Case studies in practice

  • Payments companies combine models with rules, review queues and customer friction budgets, and measure fraud in basis points of payment volume.
  • Earth-observation missions screen clouds onboard (for example ESA’s Φ-Sat-1 in 2020) so that the limited downlink carries useful scenes.
  • Predictive maintenance in aviation and energy alerts on smoothed sensor trends with lead times set by maintenance logistics.
  • Clinical models are validated at each new site; prevalence and calibration checks precede any change of threshold.
  • Ad platforms monitor calibration of click predictions continuously because predictions set prices.
  • Incident reviews of ML systems repeatedly find skew between training and serving pipelines; feature logging at serving time is the standard defence.

References

  1. C. Elkan (2001). “The foundations of cost-sensitive learning.” IJCAI.
  2. M. Saerens, P. Latinne and C. Decaestecker (2002). “Adjusting the outputs of a classifier to new a priori probabilities.” Neural Computation.
  3. A. Dal Pozzolo, G. Boracchi, O. Caelen, C. Alippi and G. Bontempi (2018). “Credit card fraud detection: a realistic modeling and a novel learning strategy.” IEEE Transactions on Neural Networks and Learning Systems.
  4. E. Breck, S. Cai, E. Nielsen, M. Salib and D. Sculley (2017). “The ML test score: a rubric for ML production readiness and technical debt reduction.” IEEE Big Data.
  5. G. Giuffrida and colleagues (2022). “The Φ-Sat-1 mission: the first on-board deep neural network demonstrator for satellite Earth observation.” IEEE Transactions on Geoscience and Remote Sensing.
  6. H. B. McMahan and colleagues (2013). “Ad click prediction: a view from the trenches.” KDD.