A search engine returns 4 results for three queries with binary relevance [0,1,0,1], [1,0,1,0] and [0,0,1,0], where 1 means relevant and each query has exactly 2 relevant documents in the corpus. What are MRR and MAP, and when would you prefer each?

ML systems and evaluation, Ranking metrics
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can compute reciprocal rank and average precision accurately—including handling unretrieved relevant documents—and pick the right ranking metric.

Key idea

MRR averages 1/rank1 across queries (where rank1 is the position of the first relevant hit), whereas MAP averages AP=1R∑kP@k⋅relk across queries, where P@k is precision at rank k, relk∈{0,1} indicates relevance at rank k, and R is the total number of relevant documents in the corpus.

Steps

  1. Compute reciprocal rank (RR) for each query from the first relevant rank: RR1=1/2=0.500, RR2=1/1=1.000, RR3=1/3≈0.333.
  2. Average to get MRR=13(0.5+1+1/3)=1118≈0.611.
  3. Compute average precision (AP) with R=2 total relevant items per query: for query 1, hits at ranks 2 and 4 give P@2=1/2 and P@4=2/4, so AP1=12(1/2+1/2)=0.500.
  4. For query 2, hits at ranks 1 and 3 give AP2=12(1/1+2/3)=5/6≈0.833; for query 3, one hit at rank 3 (and the second relevant item missed) gives AP3=12(1/3+0)=1/6≈0.167.
  5. Average to get MAP=13(1/2+5/6+1/6)=0.500. Use MRR for navigational or question-answering tasks where one good answer suffices, and MAP when the user needs all relevant items retrieved high up.

Common mistakes

How long your answer should be

Five lines of arithmetic and two sentences comparing MRR and MAP; 3–4 minutes.

Last checked on 4 December 2026.

Read this

Previous in ML systems and evaluation: A regression model predicts y^=[2,4,6,8] for true targets y=[2,4,6,12]. What are the MAE and RMSE, why is RMSE strictly larger here, and when is each metric preferred?
Next in ML systems and evaluation: You are training a pneumonia detector on 5,000 chest X-rays collected from 500 patients (10 scans per patient). Why does standard or stratified k-fold cross-validation overestimate test accuracy, and how does group k-fold fix it?