A search system returns four documents whose graded relevance, in rank order, is (higher is more relevant; 0 is irrelevant). What are precision@3 and NDCG@4, using ?
ML systems and evaluation, Ranking metrics
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can compute position-aware ranking metrics and normalise them correctly.
Key idea
Precision@k is the fraction of the top results that are relevant. DCG (discounted cumulative gain) adds up relevance grades, dividing each by so that lower ranks count less. NDCG@k (normalised DCG) discounts graded gains by and divides by the DCG of the ideal ordering, so it lies in .
Steps
- Precision@3: treat as relevant. The top 3 are , with 2 relevant, so .
- DCG@4: .
- Ideal order : .
- . The only mistake is swapping the relevance-1 and relevance-0 documents near the bottom, which costs little.
- Contrast: precision ignores grades and order within the top ; NDCG rewards putting the most relevant items first. Mention MRR (the reciprocal rank of the first relevant item) and the alternative gain , which emphasises highly relevant documents.
Common mistakes
- Computing IDCG only from the returned list when other relevant documents exist that were not returned. IDCG should use the best possible ranking of all judged documents.
- Using instead of , which divides by zero at rank 1.
- Using different gain conventions ( versus ) for DCG and IDCG.
How long your answer should be
Four lines of arithmetic and two sentences of interpretation; about 3 minutes.
Last checked on 4 December 2026.
Read this
Previous in ML systems and evaluation: What is the difference between covariate (data) drift and concept drift, what is an example of each, and how would you detect each in production?
Next in ML systems and evaluation: Why is ordinary shuffled k-fold cross-validation wrong for time-series data, and what should you do instead?