Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Evaluating Ranked Results

Precision and recall treat a result set as a bag: a document is either in the set or not, and the metrics do not change if the order is shuffled. A ranked retrieval system does more than decide which documents to return; it decides which ones to show first. A user who reads from the top and stops after five items gets a very different experience depending on whether the relevant books are at ranks 1 and 2 or at ranks 16 and 18. Evaluation must account for position, not only membership.

Recall the first five positions from Designing a Retrieval Benchmark:

RankSystem A resultUseful?System B resultUseful?
1Computer Organization and DesignyesDatabase Systems: The Complete Bookyes
2Operating System ConceptsyesPattern Recognition and Machine Learningyes
3The Handmaid’s TalenoIntroduction to Algorithmsyes
4Narrative of the Life of Frederick DouglassnoOn the Origin of Speciesno
5Towards a New ArchitecturenoIntroduction to the Theory of Computationyes

System A retrieves 25 books total (12 of 15 relevant); System B retrieves 8 (6 of 15 relevant). The set-based precision numbers from Precision and Recall already showed that B is more precise overall, but ranking adds a second dimension: how quickly does the user reach useful material? System A places two relevant books at the top, then three misses; System B delivers four of five.

Precision at Rank k

The simplest rank-aware metric evaluates only the first kk positions. Precision at rank kk counts how many of the top-kk documents are relevant, ignoring everything below.

P@kP@k answers one practical question: if the user reads only the first kk items, what proportion is useful? It does not require knowing how many relevant documents exist in the collection, which makes it easy to compute and interpret. It also does not penalize a system for missing relevant documents below rank kk: a system that places one relevant book at rank 1 and nothing else achieves P@1=1.0P@1 = 1.0 regardless of how many relevant books it missed.

System B dominates at every cutoff. A student who reads the first five results gets four useful books from B but only two from A. P@kP@k captures this user experience directly.

Reciprocal Rank and MRR

Some information needs have a single correct answer, or the user is satisfied as soon as one relevant result appears. A library patron asking “Who wrote Dracula?” needs exactly one fact; seeing it at rank 1 is ideal, at rank 20 is frustrating. The reciprocal rank captures this notion.

RR=1RR = 1 when the first result is relevant; RR=0.5RR = 0.5 when the first relevant result is at rank 2; RR→0RR \to 0 as the relevant document is pushed further down. If no relevant document appears in the result list at all, RR=0RR = 0.

MRR is widely used in question answering and known-item search, where one good answer suffices. It ignores what happens after the first relevant document: a system that places five relevant books at ranks 1 through 5 scores the same RR=1RR = 1 as one that places a single relevant book at rank 1 and nothing else. For needs where multiple relevant documents matter, as in our CS-foundations example with 15 relevant books, MRR is the wrong tool.

The Precision-Recall Curve

P@kP@k evaluates one fixed cutoff. A more complete picture plots precision against recall at every rank where a relevant document appears. As the system returns more documents, recall increases (more relevant documents are found) and precision typically decreases (more non-relevant documents accumulate). Plotting precision against recall produces the precision-recall curve.

At each rank ii in the result list, define:

Pi=∣{d1,…,di}∩Rel∣iRi=∣{d1,…,di}∩Rel∣∣Rel∣P_i = \frac{|\{d_1, \ldots, d_i\} ∩ \text{Rel}|}{i} \qquad R_i = \frac{|\{d_1, \ldots, d_i\} ∩ \text{Rel}|}{|\text{Rel}|}

A point (Ri,Pi)(R_i, P_i) is recorded only at ranks where a relevant document is retrieved: those are the only ranks where recall changes. Between two relevant documents, recall stays constant while precision drops (the denominator ii grows with no new relevant hit), so these in-between ranks do not add new curve points.

Reading the Curve

Figure 1 annotates the key regions of a precision-recall curve. The upper-left corner (high precision, low recall) is where a fact-checker operates: a short, clean result list with few mistakes. The lower-right corner (high recall, low precision) is where a patent lawyer operates: an exhaustive search that tolerates noise to avoid missing anything. The diagonal arrow labelled “system efficiency” points toward the ideal corner (1,1)(1, 1): the closer a curve pushes toward that point, the better the system balances both goals simultaneously.

Precision-recall curve with key evaluation landmarks: the shaded area is Average Precision (AP), R-precision marks the point where the number of results equals the number of relevant documents, and the two user profiles illustrate the trade-off between precision-oriented and recall-oriented search.

Figure 1:Precision-recall curve with key evaluation landmarks: the shaded area is Average Precision (AP), R-precision marks the point where the number of results equals the number of relevant documents, and the two user profiles illustrate the trade-off between precision-oriented and recall-oriented search.

The shaded area under the curve represents Average Precision (AP), which the next subsection defines formally. The figure marks R-precision at rank RR, where RR is the number of relevant documents. At this cutoff, precision and recall are numerically equal because both divide the number of relevant documents retrieved in the first RR positions by RR.

Interpolation for Cross-System Comparison

The 12 points in the table above form a smooth, largely decreasing scatter for one system and one need. The need for interpolation arises when we want to compare two systems or average curves across multiple needs: each system produces points at different recall levels, so we cannot directly subtract or average their precisions. Interpolation defines precision at any recall level rr as the maximum precision achieved at any recall level r′≥rr' \geq r:

Pinterp(r)=max⁡r′≥rP(r′)P_{\text{interp}}(r) = \max_{r' \geq r} P(r')

This produces a non-increasing step function evaluated at standard recall levels (0, 0.1, 0.2, ..., 1.0). Two systems evaluated on the same 11 recall points can be compared point by point or averaged across queries. For System A, interpolated precision at recall 0 is 1.0 (the best precision it ever achieves), while at recall 0.9 and 1.0 it is 0 (the system never reaches those recall levels).

R-Precision

R-precision links precision to recall through a single number. If the collection contains RR relevant documents for a need, R-precision is the precision after exactly RR documents have been retrieved.

R-Prec=P@R=∣{D1,…,DR}∩Rel∣R\text{R-Prec} = P@R = \frac{|\{D_1, \ldots, D_R\} ∩ \text{Rel}|}{R}

A perfect system would place all RR relevant documents in the first RR positions, achieving R-precision of 1.0. The measure adjusts itself to the difficulty of the need: a need with 15 relevant documents (our CS-foundations example) evaluates at cutoff 15, while a need with 2 relevant documents evaluates at cutoff 2.

R-precision is simple and self-adjusting, but it reduces an entire ranking to one point. The metrics that follow evaluate the full curve.

Average Precision

Average precision (AP) collapses the precision-recall curve into a single number. Geometrically, it approximates the area under the precision-recall curve: the shaded region in Figure 1. A system whose curve stays high across all recall levels has a large area and a high AP; one whose precision collapses early has a small area and a low AP.

The computation is straightforward: at each rank where a relevant document appears, record the precision at that rank. Then take the mean of those values, using the total number of relevant documents in the collection as the divisor.

Dividing by ∣Rel∣|\text{Rel}| rather than by the number of relevant documents actually found means that missed documents contribute implicit zeros: they never appear in the ranking, so they add nothing to the numerator, but the denominator still counts them. This is what makes AP sensitive to recall, not only to precision at the top.

AP uses the raw (non-interpolated) precision values. Interpolation serves a different purpose: it defines precision at arbitrary recall levels so that curves from different systems can be compared point by point or averaged. AP does not require that step because it sums only at the fixed rank positions where relevant documents actually occur.

AP rewards both placing relevant documents high (each precision term is larger when fewer non-relevant documents precede it) and finding more relevant documents (more terms contribute to the sum). This makes it the single best summary of a ranking for a given need: unlike P@kP@k it accounts for the full list, and unlike MRR it values every relevant document, not only the first.

Mean Average Precision

Evaluating a system on one need gives one AP value. A benchmark with multiple needs produces an AP per need, and mean average precision (MAP) averages them.

MAP=1∣Q∣∑i=1∣Q∣APiMAP = \frac{1}{|\mathbb{Q}|}\sum_{i=1}^{|\mathbb{Q}|} AP_i

MAP is a macro-average: each need contributes equally regardless of how many relevant documents it contains. This is the same averaging strategy discussed in Precision and Recall, and the same caveats apply: a need with one relevant document has as much influence on MAP as a need with fifteen.

MAP is the standard primary metric in TREC and most retrieval benchmarks. A single MAP value summarizes an entire system’s behaviour across all evaluated needs. When two systems are compared, a paired test (such as a paired tt-test or Wilcoxon signed-rank test) on the per-need AP values determines whether the difference is statistically significant, not just the result of a few easy or hard queries.

Choosing a Metric

Each metric answers a different question about the ranking:

MetricQuestion it answersSensitive to
P@kP@kHow clean are the first kk results?Precision at a fixed cutoff
MRRMRRHow quickly does the user find one good result?Position of the first relevant document
R-Prec\text{R-Prec}How well does the system fill the first RR slots?Balance of precision and recall at a natural cutoff
APAPHow good is the overall ranking for one need?Both precision and recall, position-weighted
MAPMAPHow good is the system across many needs?Per-need AP, macro-averaged

P@kP@k and MRR suit settings where users inspect only the top few results: web search, question answering, voice assistants. AP and MAP suit settings where the full ranking matters: patent search, systematic reviews, benchmark comparisons. R-precision provides a single summary that adjusts to the number of relevant documents per need.

All of these metrics treat relevance as binary: a document is relevant or it is not. The next section relaxes this assumption, introducing graded relevance where some documents are more useful than others, and metrics that reward a system for placing highly relevant documents above marginally relevant ones.