Skip to content
mlmentorship

Ranking metrics: NDCG, MAP, MRR

Beyond binary precision-recall: how to measure ranking quality when order matters and labels are graded.

Published · 5 min read ·Role-specific ·Intermediate

Visual quick review

Visual first · depth when needed

Trace what NDCG, MAP, and MRR count as credit while scanning a ranked list, then choose the metric whose relevance labels and stopping behavior match the task.

Preparing the visual…

Summary

Ranking metrics evaluate ordered lists of items. NDCG (Normalized Discounted Cumulative Gain) handles graded relevance with position discount. MAP (Mean Average Precision) handles binary relevance averaged over recall levels. MRR (Mean Reciprocal Rank) handles a single correct answer per query.

Search, recommendation, retrieval, and question-answering systems produce ranked lists, not classifications. Treating these problems as classification (precision / recall / F1) ignores order. A wrong top-1 hurts more than a wrong top-10. Ranking metrics quantify “right things at the top.”

For senior interviews, knowing which metric to use for which ranking problem is expected.

NDCG. The dominant ranking metric

For a query with predicted ranking and ground-truth relevance grades (e.g., 0 = irrelevant, 1 = relevant, 2 = highly relevant):

Discounted Cumulative Gain at :

The numerator rewards high-relevance items more than linearly. The denominator (the discount) penalizes putting relevant items deeper.

NDCG normalizes by the ideal ranking’s DCG so scores live in [0, 1]:

Average NDCG across queries to get a system-level metric.

Why NDCG is the default: handles graded relevance, position-discounts deeper results, normalized for cross-query comparison, has standardized (NDCG@5, @10).

MAP. Average precision averaged over queries

For a query with binary relevance:

Precision at position : .

Average Precision:

where is total relevant items. Averages precision over the recall levels at which relevant items appear.

MAP (Mean Average Precision) = average AP across queries. Used heavily in information retrieval (TREC) before NDCG took over for graded relevance.

MRR. When there’s one right answer

For each query with a single correct answer at position (or no correct in top-K):

MRR = mean of RR across queries. Used in: question answering (one correct answer per question), passage retrieval (one gold passage per query), some entity disambiguation.

Learning objective

Trace what each metric counts as credit while scanning from rank 1 downward.

Many relevant items: graded or binary?

The same four results support two different judgments.

RankGradeNDCG creditAP checkpoint
13 · relevant(2³−1) / 1 = 7.001 / 1
20 · not relevant0Skip
32 · relevant(2²−1) / 2 = 1.502 / 3
41 · relevant(2¹−1) / 2.32 = 0.433 / 4

NDCG@4 = 8.93 / 9.39 = 0.95
AP = (1 + 2/3 + 3/4) / 3 = 0.81

One correct answer: stop at the first hit

MRR ignores later ranks once the answer is found.

RankAnswer?MRR action
1WrongContinue
2WrongContinue
3CorrectStop

RR = 1 / first correct rank = 1 / 3 = 0.33

Read it this way: scan the left table by row. NDCG uses every grade and discounts lower ranks; AP uses only relevant rows and records precision at each hit. Use the right table only when one answer matters: MRR stops at the first correct result. The calculations are an original example checked against the original cumulative-gain paper, the IR textbook definition of MAP, and the TREC-8 QA evaluation.

Hit rate and recall@K

Hit rate@K (or recall@K): fraction of queries where a relevant item appears in the top . Used heavily in retrieval / candidate-generation evaluation, where the goal is “get the gold into the candidate pool” and a downstream ranker handles ordering.

MetricOrder matters?Graded relevance?Multi-relevant per query?
NDCGYesYesYes
MAPYesNo (binary)Yes
MRRYesNoOne per query
Recall@KNo (just need in top-K)NoYes
Precision@KNoNoYes

When to use which

  • Web search, e-commerce search: NDCG@10 (graded relevance, deep results matter less).
  • Recommendations with implicit feedback: NDCG@K with binary relevance, or hit rate@K.
  • Information retrieval academic benchmarks: MAP (TREC tradition).
  • Question answering, fact retrieval: MRR (one correct answer).
  • Retrieval candidate generation: Recall@K (downstream ranker handles order).
  • Top-1 critical applications: precision@1 or accuracy.

Common pitfalls

  • Reporting NDCG at one : report NDCG@5, @10, @20 to show whether order or coverage matters more.
  • Comparing NDCG across systems with different relevance grading scales. A system rated on a 0-3 scale gives different NDCG than the same system on 0-4. Standardize.
  • Treating MRR as MAP for QA. If there can be multiple correct answers, MAP is more informative.
  • Using accuracy for ranking. Accuracy ignores order entirely; nearly always wrong choice for ranking problems.
  • Confusing macro vs. micro averaging across queries. Standard ranking metrics average per-query (one score per query, then mean). Analogous to macro. Don’t pool TP/FP across queries.