Braj Kishore
JourneyVaultML FoundationsAI PM GuideAgenticNewsWork With MeMentorshipPulseNow
Say hi

Hiring · Building · Investing

Have a system — or a team —that needs to scale?

info@avyxon.ai

Usually replies within a day · track record here

JourneyVaultML FoundationsAI PM GuideAgenticNewsWork With MeMentorshipPulseNow
LinkedInXYouTubeSubstackInstagramThreadsFacebookDiscordGitHubTopmate
© 2026 Braj Kishore · Bengaluru, INThink Big · Start Small · Scale Fast
ML Foundations
08Track 2 · The training loop

Evaluation that survives production

The accuracy trap, the confusion matrix, precision/recall trade-offs, ROC vs PR, calibration — and why the threshold is a product decision, not a model property.

55 min1 interactive6 sources

A fraud model that predicts 'not fraud' for every transaction is 99.9% accurate on a 0.1% fraud rate, catches nothing, and would pass a naive review. Accuracy is the most-quoted and least-informative number in machine learning.

The intuition

Precision answers: when the alarm goes off, how often is there really a fire? Recall answers: of all the fires, how many set off the alarm? A smoke detector that screams at toast has high recall and terrible precision. One you disconnected has perfect precision on the zero alarms it raises.

Unlearn this

That a classifier outputs a class. It outputs a score; a threshold turns that score into a class, and the threshold is yours to choose from the relative cost of the two error types. Reporting a single precision/recall pair without saying which threshold produced it is close to meaningless.

01The confusion matrix and everything derived from it

Four cells: true positives, false positives, false negatives, true negatives. Every classification metric worth knowing is a ratio of these, so memorise the matrix and derive the rest rather than memorising formulas.

Precision = TP / (TP + FP) — of everything you flagged, how much was real. It's the metric to optimise when a false positive is expensive: blocking a legitimate payment, quarantining a real email, telling a healthy patient they're ill.

Recall (sensitivity) = TP / (TP + FN) — of everything real, how much you caught. Optimise it when a miss is expensive: an undetected tumour, a missed fraudulent transfer, a security breach that goes unflagged.

F1 is their harmonic mean, which punishes imbalance between them — 0.9 and 0.1 gives F1 of 0.18, not 0.5. It's a reasonable single number when the two errors cost about the same, and a poor one when they don't. If a false negative costs ten times a false positive, say so and use a weighted Fβ or an explicit cost function instead of pretending F1 captures it.

Precision = TP/(TP+FP) · Recall = TP/(TP+FN)

Of what you flagged, how much was real · of what was real, how much you flagged.

F1 = 2PR/(P+R)

Harmonic mean — heavily penalises a lopsided pair. Only fair when both error types cost the same.

Machine Learning Fundamentals: The Confusion MatrixStatQuest with Josh Starmer

Try it

Threshold, prevalence, and the metrics

Drag the threshold. Then set prevalence to 1% and watch ROC-AUC refuse to notice what precision is doing.

02The threshold is a product decision

The model gives a score between 0 and 1. Everything above the threshold is a positive prediction. Move the threshold down and you catch more real positives and also more false alarms; move it up and the reverse. Precision and recall are two ends of one lever, and no amount of model improvement removes the trade-off — a better model just gives you a better curve to pick a point on.

So set it from the economics. If a false positive costs £2 in support handling and a false negative costs £180 in chargebacks, the threshold that minimises expected cost is far below 0.5, and 0.5 was never a principled default — it's just the midpoint of the range.

This is also where a good answer separates the model from the system. You can operate at more than one threshold: auto-approve below a low score, auto-decline above a high one, and route the ambiguous middle band to a human. That turns the precision/recall trade-off into a review-cost dial, which is very often the right product design.

The point

Quote metrics as 'recall at 95% precision' or 'precision at 90% recall', never a naked F1. Fixing one side makes the number comparable between models and forces the conversation about cost.

03ROC-AUC, PR-AUC, and when ROC lies

ROC plots true positive rate against false positive rate as the threshold sweeps from 1 to 0; the area under it is the probability that a randomly chosen positive scores higher than a randomly chosen negative. It's threshold-independent, which makes it a good single number for comparing models.

Its weakness shows under heavy imbalance, and this is one of the most reliable senior interview questions. The false positive rate has TN in its denominator, and with 99.9% negatives TN is enormous — so thousands of false positives barely move the FPR and the ROC curve stays flattering. A model can post 0.95 ROC-AUC and still return mostly false alarms in the top 100 results.

Precision-recall AUC has no TN anywhere in it, so it tracks exactly the thing that hurts in imbalanced problems. Rule of thumb: for balanced problems, ROC-AUC. For imbalanced problems, or whenever the positive class is what you care about, PR-AUC (average precision) — and the baseline is the positive rate, not 0.5, so 0.4 average precision on a 1% positive class is excellent, not poor.

ROC and AUC, Clearly Explained!StatQuest with Josh StarmerClassification: ROC and AUCGoogle ML Crash CourseThe Precision-Recall Plot Is More Informative than the ROC Plot on Imbalanced DatasetsSaito & Rehmsmeier, PLOS ONE · 2015

04Calibration: when the number has to mean something

A model is calibrated if, among the cases it scores 0.7, about 70% are actually positive. Ranking metrics don't test this at all — a model can rank perfectly and still output probabilities that are systematically far too confident.

It matters whenever anything downstream consumes the number rather than the ranking: expected-value calculations, cost-based thresholds, risk aggregation, a human reading '80% likely'. Modern deep networks are notoriously overconfident, and class weighting or resampling makes it worse.

Measure it with a reliability diagram — bucket predictions by score, plot the observed positive rate against the mean predicted score, and compare to the diagonal — plus expected calibration error as a single number. Fix it post-hoc with Platt scaling (fit a logistic regression on the scores) or isotonic regression, both fitted on a held-out calibration set, not on train.

On Calibration of Modern Neural NetworksGuo et al., ICML · 2017Probability calibrationscikit-learn

05Offline metrics, online reality, and the baseline

Offline metrics measure the model against a frozen dataset. Online metrics measure the product against the world, where the model's own predictions change user behaviour and therefore change the next batch of training data — a feedback loop no offline evaluation captures. A recommender that only ever shows what it already thinks you'll like will never learn that you'd have liked something else.

The staged sequence that catches most problems: offline eval on a time-based holdout, then shadow mode (the model scores live traffic but its output isn't used, so you compare distributions against production), then a small A/B or interleaving experiment on the real metric, then a staged ramp with a pre-committed rollback trigger.

And always ship a stupid baseline first. Predict the majority class. Predict yesterday's value. Use a keyword rule. Use logistic regression on five features. If the deep model doesn't clearly beat the stupid baseline on the metric that pays rent, you've learned something extremely valuable for the price of an afternoon.

In an interview

"How do you know your model is working in production?" — Don't answer with offline metrics. Answer with: a business metric in an A/B test, prediction-distribution monitoring for drift, and a pre-committed rollback trigger. Then mention shadow mode.

The vocabulary, defined once
Confusion matrix
TP/FP/FN/TN. Derive every classification metric from it rather than memorising formulas.
Precision / Recall
Of what you flagged, how much was real / of what was real, how much you flagged. Two ends of the threshold lever.
F1 / Fβ
Harmonic mean of precision and recall; β weights recall over precision when a miss costs more than a false alarm.
ROC-AUC
Probability a random positive outranks a random negative. Threshold-free, but flattering under heavy imbalance.
PR-AUC (average precision)
No true negatives in the maths, so it stays honest on imbalanced problems. Baseline is the positive rate.
Calibration
Do the scores mean what they say? Required whenever anything downstream uses the probability, not just the ranking.
Shadow mode
Run the model on live traffic without acting on its output. Catches distribution surprises before users feel them.

The lab

Everything above, with the dials exposed. Break it deliberately — the failure modes are where the understanding is.

Try it

Threshold, prevalence, and the metrics

Drag the threshold. Then set prevalence to 1% and watch ROC-AUC refuse to notice what precision is doing.

What they actually ask

Evaluation that survives production — the interview questions

QYour fraud model has 99.9% accuracy. Are you happy?Answer it out loud first, then open this

No — with a 0.1% fraud rate, predicting 'never fraud' scores exactly that. I'd want the confusion matrix, precision and recall at the operating threshold, average precision rather than ROC-AUC because of the imbalance, and the money: what fraud value is caught versus what legitimate volume is blocked. Accuracy on an imbalanced problem tells you the base rate, not the model.

QHow do you choose the classification threshold?Answer it out loud first, then open this

From the cost of each error type, not from 0.5. Estimate the cost of a false positive and a false negative, then pick the threshold minimising expected cost — or fix the constraint the business actually has, like 'maximise recall subject to precision ≥ 90%' because that's the review capacity. Better still, use two thresholds and send the uncertain band to a human.

What they're listening for
The two-threshold answer — auto-approve, auto-decline, human middle — is the one that reads as having shipped a real system.

QOffline metrics improved but the A/B test is flat. What's going on?Answer it out loud first, then open this

Candidates: the offline set doesn't reflect live traffic (stale, or a random rather than time-based split); the metric improved somewhere users don't feel it — for example better on the tail while the head is unchanged; a feedback loop, where the offline set was collected under the old model's policy; latency regression eating the quality gain; or the experiment is underpowered and 'flat' just means not yet significant. I'd check the power calculation before concluding anything.

Before you move on

Recall beats re-reading, every time. Answer before you flip.

Evaluation that survives production · self-test1 / 3

When is ROC-AUC misleading?

Go to the primary sources

Where each claim above comes from. Open them alongside the lesson rather than after it — the papers are shorter than you think, and the figures usually carry the whole argument.

Paper
  • The Precision-Recall Plot Is More Informative than the ROC Plot on Imbalanced Datasets(2015)Saito & Rehmsmeier, PLOS ONEThe citation to reach for when someone insists on ROC-AUC for a 1%-positive problem. Quantifies exactly how ROC flatters.
  • On Calibration of Modern Neural Networks(2017)Guo et al., ICMLDocuments that modern deep networks are badly overconfident, and introduces temperature scaling as the one-parameter fix.
Watch
  • Machine Learning Fundamentals: The Confusion MatrixStatQuest with Josh StarmerSeven minutes to fix the TP/FP/FN/TN confusion permanently, including the multi-class generalisation.
  • ROC and AUC, Clearly Explained!StatQuest with Josh StarmerBuilds the ROC curve threshold by threshold. Watching it get drawn is what makes 'threshold-independent' click.
Docs
  • Classification: ROC and AUCGoogle ML Crash CourseThe written companion, with the probabilistic interpretation of AUC and an interactive threshold widget.
  • Probability calibrationscikit-learnReliability diagrams, Platt scaling and isotonic regression, with the code and the warning about fitting on training data.

External links open in a new tab. Every URL was reachable when this page was written; links rot, so treat the list as a map rather than a guarantee.

Connects to

Setting the shipping bar, for PMs

Got it? Tick it off — progress saves on this device.

← PreviousFit & generalisationNext →Feed-forward networks (ANN / MLP)
Threshold, prevalence, and what the metrics do about it30.0% positive
thresholdscore 0 — predicted negative1 — predicted positive

TP2,501

caught

FP1,165

false alarm

FN499

missed

TN5,835

correctly ignored

Precision

68.2%

of what you flagged

Recall

83.4%

of what was real

F1

75.0%

harmonic mean

Accuracy

83.4%

usually a lie

FPR →TPR ↑
ROC · AUC 0.916
recall →precision ↑
PR · AP 0.847
— not 0.5, which was only ever the midpoint of the range.
At threshold 0.50: 2,501 caught, 499 missed, 1,165 false alarms. Raise the threshold and precision climbs while recall falls — the same model, a different operating point. That is the product decision, and it belongs to whoever owns the cost of each error, not to the model.

Drag the threshold and watch precision and recall move in opposite directions. Then drop prevalence to 1% and watch ROC-AUC refuse to notice while precision falls through the floor.

Threshold, prevalence, and what the metrics do about it30.0% positive
thresholdscore 0 — predicted negative1 — predicted positive

TP2,501

caught

FP1,165

false alarm

FN499

missed

TN5,835

correctly ignored

Precision

68.2%

of what you flagged

Recall

83.4%

of what was real

F1

75.0%

harmonic mean

Accuracy

83.4%

usually a lie

FPR →TPR ↑
ROC · AUC 0.916
recall →precision ↑
PR · AP 0.847
— not 0.5, which was only ever the midpoint of the range.
At threshold 0.50: 2,501 caught, 499 missed, 1,165 false alarms. Raise the threshold and precision climbs while recall falls — the same model, a different operating point. That is the product decision, and it belongs to whoever owns the cost of each error, not to the model.

Drag the threshold and watch precision and recall move in opposite directions. Then drop prevalence to 1% and watch ROC-AUC refuse to notice while precision falls through the floor.