Offline Evaluation: Metrics That Fit the Task
You'll learn to
- -Choose an offline metric that matches what the system is used for
- -Compute precision at k and NDCG for a ranker, and explain why NDCG rewards order
- -Explain calibration, and show why a good AUC does not guarantee it
- -List reasons offline metrics and online results disagree
A model's offline score is the number you have before you have any users. It decides which model gets built, which change ships, and which idea is dropped. If the metric does not fit the task, those decisions are wrong, however carefully they are made.
An Analogy: Choosing the Right Instrument
A bathroom scale measures weight, not height. A tape measure does the opposite. Neither is wrong, but using the wrong one gives you a precise number that answers a question you did not ask. Metrics are instruments. The task decides which to use.
Match the Metric to the Task
- -Classification (spam or not, fraud or not): precision, recall, and the precision-recall curve. Use them with a chosen threshold. The classification metrics chapter earlier in this course covers these in depth.
- -Ranking and recommendation: precision at k, recall at k, mean reciprocal rank, mean average precision, and NDCG. These care about the order of results, because a user sees the top few.
- -Regression (ETA, price, demand): mean absolute error, root mean squared error, and quantile loss when over and under predictions cost different amounts.
- -Probability estimates (click rate, conversion): log loss and calibration, because the number itself is used, for example to price an ad.
Ranking Metrics
Precision at k asks: of the top k results, how many are relevant? It ignores the order inside the top k. NDCG, normalized discounted cumulative gain, fixes that. It gives each result a gain based on its relevance grade, discounts the gain by how far down the list it sits, and divides by the best possible score so that 1.0 is a perfect ordering.
Calibration
A calibrated model's numbers mean what they say: of all the cases it scores at 10%, about 10% really happen. This matters whenever the score is used as a probability. An ad auction multiplies the predicted click chance by the bid, and a model that is twice as confident as it should be makes every ad look twice as valuable.
AUC measures ranking: does the model put positives above negatives? It does not care about the scale of the scores. Double every score and the ranking, and the AUC, stay exactly the same, but the probabilities are now wrong. The code below has two parts. The first scores two rankers on three queries with graded relevance. The second builds two models that rank customers identically, where model B simply doubles model A's scores. Press Run and compare the AUC and the average predicted rate in the lower table.
Ranker B beats ranker A on both ranking metrics: precision at 3 is 1.00 against 0.56, and NDCG at 5 is 0.938 against 0.774. Ranker A puts a zero-relevance result in the top three on every query, which is what drags it down. In the lower table, models A and B have the same AUC, 0.781, since B only rescales A. But the average predicted rate for B is 15.5% while the true rate is 7.6%, and its log loss is worse, 0.2659 against 0.2325. Log loss and calibration see what AUC cannot.
More Ways Offline Metrics Mislead
- -Averages hide slices. A model can be good overall and bad for new users, one country, or one device. Report the metric by segment.
- -Random splits leak time. When data has a time order, train on the past and test on the future.
- -Feedback loops and position bias. Logged clicks reflect what the old system chose to show, so a better new ranker can look worse on old logs.
- -Metric mismatch. The offline metric is a proxy. A better NDCG does not guarantee more engagement, which is why launches need an online experiment.
Choose your offline metrics before you see results, write down the minimum improvement that would justify a launch, and keep a metric on each segment you care about. Then treat the offline number as a filter for what to test online, not as the verdict.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.
Discussion0
Join the Discussion
Sign in to leave comments, reply to others, or like insights.
No comments yet. Be the first to start the thread!