ML Systems Lab Open interactive version →
Advanced 24 min read calibrationguardrailscounterfactualoff-policyevaluation

Calibration, Guardrails & Counterfactual Eval

Why ranking scores must be probabilities, and how to trust offline numbers

For pure ranking, only the *order* of scores matters — so why calibrate? Because at staff scale the score rarely stays a pure ranking score. The moment it feeds an ad auction (expected value = pCTR × bid), a value model (weighted sum of heads), or a threshold ("auto-approve if fraud prob < 0.01"), the *number* matters, not just the order. An uncalibrated 0.9 that's really 0.6 systematically overbids, mis-weights, and mis-thresholds.


Calibration means the number is a probability. Of all items scored 0.7, about 70% should be positive. Measure it with a reliability diagram and Expected Calibration Error; fix it with Platt scaling or isotonic regression on a held-out set. Deep rankers are systematically overconfident, so calibration is a required post-processing step whenever the score is consumed as a probability.


Guardrail metrics catch the harm your objective ignores. You optimize engagement; you *guard* the metrics that must not regress — latency, harmful-content rate, creator diversity, complaint rate. In every A/B test the primary metric can win while a guardrail quietly breaks; a launch that lifts engagement 2% but raises the report rate 15% should not ship. Guardrails are the veto, not the goal.


Counterfactual (off-policy) evaluation lets you estimate a new ranker's online performance from logged data, before serving it. Because logs were collected under the *old* policy, you reweight by inverse propensity (how likely the old policy was to show each item — an item the old policy showed only 5% of the time gets its logged outcome weighted ×20, since 1/0.05 = 20) to estimate what the *new* policy would have earned. It's how you kill bad candidates before they ever touch live traffic.

Key points

Takeaway

Order-only thinking breaks the moment a ranking score feeds an auction, value model, or threshold — then it must be a calibrated probability; guardrail metrics veto launches that win the primary but harm users; and counterfactual (IPW) evaluation estimates a new policy's online value from old logs so bad rankers die before touching traffic.

Recap

Check your understanding

Q1. An ads system ranks by expected value = pCTR × bid. The pCTR model is a well-ordered but overconfident deep net. What breaks, and what's the fix?

Q2. Select the two correct statements about an A/B test that lifts engagement 2% (stat-sig) but raises the harmful-content report rate 15%.

Q3. You want to estimate a new ranker's online CTR from logs collected under the current ranker, before any live test. Which approach is valid and what's its main risk?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →