“Our recommendation model improved offline. Should we launch it?”
Not on that evidence alone. First identify what improved, how it was measured, and whether that result supports the product objective. Retrieval quality, ranking quality, and user value are related, but they are not interchangeable.
This guide uses small, invented examples so you can explain the reasoning in an interview. It connects directly to the video recommendation walkthrough.
01. Ask three different questions
| Stage | Question | Useful measure |
|---|---|---|
| Retrieval | Did we keep the relevant items in the candidate set? | Recall@K |
| Ranking | Are the most useful items near the top? | NDCG@K |
| Product | Did users benefit from the resulting feed? | An experiment on defined user outcomes and guardrails |
Suppose retrieval misses a relevant video entirely. A perfect ranker cannot recover it. Conversely, retrieving every relevant item is not enough if the ranker puts them below unhelpful ones.
02. Recall@K: keep the useful candidates
For one user, define a set of relevant items in the evaluation window. Recall@K is the fraction of those items present in the top K results.
Imagine the held-out relevant set is {A, B, C, D}. Retrieval returns [A, X, C, Y, Z] as its top five. It recovered two of the four relevant items, so Recall@5 = 2/4 = 0.50.
For the same list, Precision@5 is 2/5 = 0.40: it asks what fraction of the returned items were relevant. Retrieval often prioritizes recall because later stages can discard weak candidates, but larger K also increases downstream computation.
“All relevant items” usually means all known relevant items in your evaluation data. Logged clicks or watches do not reveal every video a person might have liked.
Compute metrics per user or request and state the aggregation rule. A mean across users weights each evaluated user equally; pooling counts gives more influence to users with more labels. Users with no known positives need an explicit exclusion or reporting policy because recall is undefined for a zero denominator.
03. NDCG: reward useful items near the top
Recall does not care about order within the top K. NDCG—normalized discounted cumulative gain—does. It discounts relevance at lower positions and divides by the score of an ideal ordering.
For this example, use binary relevance: 1 for a known relevant item and 0 otherwise. With linear gain:
NDCG@K = DCG@K / ideal DCG@K
Assume two items are relevant. Compare these top-three rankings:
| Ranking | Relevance by position | DCG@3 | NDCG@3 |
|---|---|---|---|
| A | [1, 0, 1] | 1 + 0 + 0.5 = 1.5 | ≈ 0.920 |
| B | [1, 1, 0] | 1 + 0.631 + 0 = 1.631 | 1.000 |
Both retrieve the same relevant items. Ranking B earns the higher score because it puts them first and second. For nonnegative labels and a nonzero ideal score, normalization makes the ideal ranking score 1.
Graded relevance can express different levels of usefulness. State whether you use linear gain or an exponential convention such as 2relevance − 1; they can value large relevance differences differently. Handle zero-ideal-score cases consistently and document the tie policy. The scikit-learn NDCG documentation provides a precise implementation reference.
04. The evaluation protocol is part of the metric
A number without its protocol is difficult to interpret. Before comparing two models, agree on these details:
- Time split: train on earlier events and evaluate on later events. Build features using only information available at prediction time.
- Candidate universe: use comparable eligible catalogs. Ranking against a few sampled negatives is a different task from ranking the whole catalog.
- Labels: define relevance, the observation window, and how delayed or missing outcomes are treated.
- Cohorts: report new users, established users, fresh items, and other product-relevant segments separately.
- Aggregation: state whether results are per user, per request, or pooled, and how uncertainty is estimated.
A concrete leakage trap
Suppose you predict Monday engagement using a feature that counts a video's likes through Friday. That feature includes the future outcome you are trying to predict. A chronological split alone will not fix it if the feature joins still use future values.
Use point-in-time feature joins and include a simple baseline in every evaluation. If an elaborate model barely beats it—or only beats it under a flawed protocol—the complexity has not been justified.
05. Connect offline quality to user value
An offline result can be misleading because your data came from the previous recommendation policy. Items it never showed have little or no outcome evidence. Position influences what users see, and the meaning of a click may not match the product's intended benefit.
Use offline evaluation to screen candidates and diagnose stages. Then, when appropriate, run a controlled experiment with a predefined primary outcome and guardrails. For a video feed, these might include meaningful engagement, return rate, hides, reports, and serving latency.
Choose the experiment unit and duration to match the question. Randomizing users may be appropriate for a personalized feed; effects involving shared creators or inventory can complicate independence. Define sample-size assumptions and stopping rules before interpreting results, and examine uncertainty rather than treating any positive difference as a win.
“An offline ranking gain tells me the model better matches our labels under this evaluation protocol. I still need to test whether those labels and the resulting feed improve the outcome users care about.”
06. Be ready for the follow-up
“Why not just use accuracy?”
Recommendation is usually about selecting and ordering a small set from many items. Accuracy over user–item pairs can be dominated by irrelevant pairs and says little about top-of-feed quality. Classification accuracy may still be a diagnostic for a specific prediction task, but it does not replace ranking evaluation.
“Recall goes up when K increases. Is that always good?”
For nested result sets, recall cannot decrease as K grows, but serving cost rises. Compare recall at a fixed K or under a fixed latency and compute budget. Choose an operating point based on the downstream ranking system.
“What if one cohort improves and another gets worse?”
Report the trade-off explicitly. Check sample sizes, baseline differences, and label quality before deciding whether a separate model, fallback, or product change is warranted. An aggregate gain does not make a severe cohort regression disappear.
Sources & further reading
- scikit-learn: NDCG score — discounted gain, normalization, and implementation behavior.
- Google Developers: accuracy, recall, and precision — foundational metric definitions.
All numerical examples are illustrative. Metric choice depends on the labels, evaluation protocol, and product objective.
Return to the recommendation-system design ↗
See how the evaluation plan fits into the full architecture.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.