Summary
Ranking metrics assign different credit to gain, coverage, precision at hits, and the first useful result. Choose the decision target, judged universe, cutoff, relevance definition, and query weights before comparing systems. A high score under one credit rule need not establish performance under another.
NDCG. The dominant ranking metric
Use nonnegative graded judgments and exponential gain for this lesson:
Discounted Cumulative Gain at :
For the hypothetical fully judged ranking [3,0,2,1] at cutoff four, DCG is .
Sort the judged grades only for the ideal reference: [3,2,1,0] gives IDCG .
NDCG normalizes by the ideal ranking’s DCG so scores live in [0, 1]:
The ratio is approximately . It lies in under the stated nonnegative-gain and common-universe conventions when IDCG is positive. Normalization does not make different gain scales or judging populations interchangeable.
MAP. Average precision averaged over queries
For a query with binary relevance:
Precision at position : .
Average Precision:
Define binary relevance as grade greater than zero; the fixture has total . Use the full-universe R denominator even when truncating at K here. Then AP@4 is . Alternative denominators, such as , define different truncated metrics and must be labeled.
MAP is the declared query-weighted mean of AP; equal-query averaging and traffic-weighted averaging target different populations.
MRR. When there’s one right answer
Let r be the first relevant rank, even if multiple relevant items exist:
MRR averages reciprocal rank over queries. The left fixture has first hit at rank one, so RR is one. The separate right-hand example has first hit at rank three, so RR is .
Learning objective
Average precision accumulates relevant hits; reciprocal rank stops at the first
Derivation
Many relevant items: graded or binary?
The same four results support two different judgments.
| Rank | Grade | DCG credit | AP checkpoint |
|---|---|---|---|
| 1 | 3 · relevant | (2³−1) / 1 = 7.00 | 1 / 1 |
| 2 | 0 · not relevant | 0 | Skip |
| 3 | 2 · relevant | (2²−1) / 2 = 1.50 | 2 / 3 |
| 4 | 1 · relevant | (2¹−1) / 2.32 = 0.43 | 3 / 4 |
NDCG@4 = 8.93 / 9.39 = 0.95
AP = (1 + 2/3 + 3/4) / 3 = 0.81
First useful answer: stop at its rank
MRR ignores later ranks once the answer is found.
| Rank | Answer? | MRR action |
|---|---|---|
| 1 | Wrong | Continue |
| 2 | Wrong | Continue |
| 3 | Correct | Stop |
RR = 1 / first correct rank = 1 / 3 = 0.33
Which metric can change if a later relevant item moves?
Hit rate and recall@K
Recall@K is retrieved relevant count divided by R; hit@K is an indicator that any relevant result was retrieved. They coincide only under particular relevance settings, such as exactly one relevant item per query.
Change Retrieval Depth
New task: Permit only two candidates to reach the next stage.
Picture and change: Set K to two without changing total R or the judged universe.
Check: The fixture has hit@2 one, recall@2 , and full-R AP@2 . One successful hit does not mean complete candidate coverage.
Use when: Candidate-generation capacity binds and the downstream stage cannot recover omitted items.
Change the Reward Target
New task: One useful answer suffices regardless of later results.
Picture and change: Use reciprocal first-hit rank instead of AP.
Check: Adding a relevant result at rank four after a first hit at rank three leaves RR at .
Use when: The user stops at the first satisfactory answer; multiple valid answers remain possible.
For R zero or IDCG zero, the corresponding ratios are undefined; this lesson excludes those queries and reports their count. Benchmark zero-value conventions are alternatives, not silent substitutions. Declare unjudged-item handling, duplicates, score ties, and query weights before evaluation; unjudged does not automatically mean irrelevant.
| Metric | Order matters? | Graded relevance? | Multi-relevant per query? |
|---|---|---|---|
| NDCG | Yes | Yes | Yes |
| MAP | Yes | No (binary) | Yes |
| MRR | Yes | No | Yes, but only first hit earns credit |
| Recall@K | No (just need in top-K) | No | Yes |
| Precision@K | No | No | Yes |
When to use which
- Graded utility: choose gains and discounts justified by the judgment/task model.
- Multiple relevant items: AP rewards precision at successive hits; recall measures coverage.
- First-answer utility: RR ignores later relevant items after the first.
- Candidate generation: inspect coverage at its actual capacity and query slices.
Common pitfalls
- Different gain scales: grades zero-to-three and zero-to-four need common semantics before comparing their exponential-gain scores.
- Wrong universe: computing IDCG over only returned items can conceal missing relevant candidates.
- Pooling queries: equal-query, traffic-weighted, and pooled-count measurements need not agree.
- One number: report intended cutoffs, uncertainty, judging coverage, and important slices rather than treating one metric as universal utility.
Related
- Precision, recall, F1. Binary classification metrics.
- Two-tower retrieval. What gets evaluated with these metrics in production.
- Learning-to-rank losses. Surrogate objectives for ordered results.
- Position bias and counterfactual ranking. Evaluation from biased interaction logs.