For a retrieved set, precision $P = TP/(TP + FP)$ is the share of retrieved documents that are relevant, and recall $R = TP/(TP + FN)$ the share of relevant documents that are retrieved. Both ignore the true negatives, which is why accuracy fails for retrieval: in a collection of 10,000 documents with 20 relevant, retrieving nothing scores 0.998. Retrieving more never lowers recall and usually lowers precision; for BM25 on Cranfield query 2, $F_1$ peaks at 0.303 with 9 documents retrieved. The F measure is the weighted harmonic mean $F_\beta = (\beta^2 + 1)PR/(\beta^2 P + R)$, or $(1 + \beta^2)TP/((1 + \beta^2)TP + \beta^2 FN + FP)$ in counts, and $\beta$ is the ratio of recall to precision at which gains in either are worth the same. Retrieval averages over queries by macro-averaging.
The thesis student's Boolean AND query returned two of the six Arctic documents, and only one of them served the need. Of the three documents the student needed, it found one. The OR query found two of the three, but brought three useless documents along. Both results are disappointing, in different ways. This article puts a number on each kind of disappointment, and then combines the two numbers to decide which result is better.
Two numbers do the first job. Precision is the fraction of retrieved documents that are relevant; recall is the fraction of relevant documents that are retrieved. What information retrieval is introduced them on the Arctic documents: the AND query has precision 0.50 and recall 0.33, and the OR query has precision 0.40 and recall 0.67. This article is their full treatment, and the ranked measures of the following articles all build on it.
Here is the route. First we read precision and recall off a four-cell table. Then we see why accuracy fails for retrieval, and trace the trade-off down a Cranfield ranking. Finally we combine the two into the F measure and average it over queries.
Precision and recall are defined for an unordered set of retrieved documents: the output of a Boolean system, or the top portion of a ranking. This article follows Manning, Raghavan, and Schütze (2008, §8.3). The numbers in it are computed by tools/experiments/eval_measures/worked_examples.py and cranfield_measures.py in the site's repository and rounded to three decimals.
The contingency table
For a larger example, suppose a collection holds 10,000 documents, of which 20 are relevant to a query. A system retrieves 40 documents, and 16 of them are relevant. The quality of that result is read from a table of four counts.
Every document in the collection falls into one of four cells, according to whether it was retrieved and whether it is relevant:
| Relevant | Nonrelevant | |
|---|---|---|
| Retrieved | true positives (TP) | false positives (FP) |
| Not retrieved | false negatives (FN) | true negatives (TN) |
For the example: TP = 16, FP = 24, FN = 4, and TN = 10,000 − 16 − 24 − 4 = 9,956. Filled in, the table reads:
| Relevant | Nonrelevant | Total | |
|---|---|---|---|
| Retrieved | 16 | 24 | 40 |
| Not retrieved | 4 | 9,956 | 9,960 |
| Total | 20 | 9,980 | 10,000 |
Precision is the fraction of retrieved documents that are relevant, computed along the top row:
$$P = \frac{TP}{TP + FP} = \frac{16}{40} = 0.4.$$
Recall is the fraction of relevant documents that are retrieved, computed down the left column:
$$R = \frac{TP}{TP + FN} = \frac{16}{20} = 0.8.$$
The system found most of what mattered, but filled more than half its output with documents that do not. Whether that is good depends on the task, and that dependence is the main lesson of this article.
The two measures share a numerator and differ in the denominator. Precision divides by what the system chose to show; recall divides by what the collection contains. A system controls the first directly, by deciding how much to retrieve. It has no control over the second.
Each can be read as a conditional probability:
- precision is $P(\text{relevant} \mid \text{retrieved})$, the chance that a retrieved document is relevant;
- recall is $P(\text{retrieved} \mid \text{relevant})$, the chance that a relevant document is retrieved.
Precision matters to a user scanning results, who pays for every nonrelevant document read. Recall matters to a user who must find everything, such as a lawyer, a patent examiner, or a systematic reviewer (see search in professional domains). Recall at a cutoff also decides the quality of a set handed to a later stage, a re-ranker or a language model, which can reorder the set but cannot add what it lacks. Evaluating Embedding Models measures first-stage retrievers this way, and Multi-Stage Ranking proves the ceiling that the first stage sets.
Recall has a practical difficulty that precision does not. It requires knowing every relevant document in the collection, including the ones the system missed. For a large collection that is rarely known exactly, which is why test collections estimate it from judged pools (see relevance judgments, pooling, and agreement).
Four cells, but precision and recall use only three of them. The fourth, the true negatives, is left out on purpose, and the measure that includes it shows why.
Why not accuracy?
In classification, the usual measure is accuracy, the fraction of all decisions that are correct:
$$\text{accuracy} = \frac{TP + TN}{TP + FP + FN + TN}.$$
For the example system, accuracy is $(16 + 9{,}956)/10{,}000 = 0.9972$. That sounds excellent.
Example (retrieving nothing is more accurate). A second system that retrieves nothing at all has a higher accuracy than 0.9972. Retrieving nothing produces 20 false negatives and 9,980 true negatives, for an accuracy of $9{,}980/10{,}000 = 0.998$. The useless system beats the useful one.
The problem is the skew of the collection. Nearly every document is nonrelevant to any given query, so the true negatives dominate the accuracy, and almost any behavior scores near 1. Users never see the true negatives and do not care about them. Precision and recall ignore the TN cell entirely. They focus on the retrieved documents and the relevant ones, which is where retrieval quality lies (Manning, Raghavan, and Schütze, 2008, §8.3).
The trade-off
Precision and recall pull against each other.
- Recall never decreases as more documents are retrieved. Retrieving the entire collection gives recall 1.
- Precision usually decreases, since each additional document is more likely to be nonrelevant once the best ones have been taken. Retrieving everything gives precision equal to the fraction of the collection that is relevant, here $20/10{,}000 = 0.002$.
A system can raise either measure at the expense of the other, so neither one alone can say whether a system is better. The Arctic queries showed the same thing on a small scale: loosening AND to OR raised recall from 0.33 to 0.67 and lowered precision from 0.50 to 0.40.
The trade-off is easiest to see by taking a ranking and cutting it at every possible depth. Query 2 of the Cranfield collection asks what are the structural and aeroelastic problems associated with flight of high speed aircraft, and 24 of the collection's 1,400 documents are judged relevant to it. BM25 ranks the documents, and each cutoff $k$ defines a retrieved set of the top $k$:
| Documents retrieved $k$ | Relevant among them | Precision | Recall | $F_1$ |
|---|---|---|---|---|
| 9 | 5 | 0.556 | 0.208 | 0.303 |
| 10 | 5 | 0.500 | 0.208 | 0.294 |
| 50 | 8 | 0.160 | 0.333 | 0.216 |
| 200 | 12 | 0.060 | 0.500 | 0.107 |
| 1,400 | 24 | 0.017 | 1.000 | 0.034 |
(The $F_1$ column is defined in the next section.)
The first three results are relevant, so precision starts at 1. Then nonrelevant documents arrive faster than relevant ones and precision falls, with small upticks wherever a relevant document appears. Recall moves only when a relevant document is retrieved, so it is a staircase. Recall reaches 0.5 only when the twelfth relevant document arrives, at rank 173, by which point precision has fallen to 0.069.
The last three relevant documents contain none of the query's terms after stemming. BM25 gives them no score at all, so they are reached only after every scored document (783 of them) has been retrieved. They are the Cranfield counterparts of the Arctic document D, which shares no word with the student's query. No cutoff gives both high precision and high recall for this query. Choosing a cutoff is choosing a point on the trade-off, and comparing two points needs a single number that combines them.
The F measure
The F measure combines precision and recall as a weighted harmonic mean. Here is the idea in one sentence: average not precision and recall themselves but their reciprocals, so that whichever of the two is small dominates the result.
Definition
The harmonic mean of two numbers is the reciprocal of the mean of their reciprocals. A weighted version gives precision weight $\alpha$ and recall weight $1 - \alpha$, with $0 \le \alpha \le 1$:
$$F = \frac{1}{\alpha \dfrac{1}{P} + (1 - \alpha) \dfrac{1}{R}}.$$
Why average reciprocals? Because $1/P$ and $1/R$ are effort ratios.
- $1/P = (TP + FP)/TP$ is the number of documents retrieved per relevant document retrieved.
- $1/R = (TP + FN)/TP$ is the number of relevant documents in the collection per relevant document found.
Averaging these and inverting gives a measure that falls quickly when either ratio is large.
It is conventional to express the weighting by a single parameter $\beta$, which says how much more recall counts than precision. It is defined by $\beta^2 = (1 - \alpha)/\alpha$, so that $\alpha = 1/(\beta^2 + 1)$. In terms of $\beta$ the same measure takes the form
$$F_\beta = \frac{(\beta^2 + 1)\, P R}{\beta^2 P + R}, \qquad \beta^2 = \frac{1 - \alpha}{\alpha}.$$
The two forms are equal for every $P > 0$, $R > 0$ and $0 < \alpha \le 1$. (Manning, Raghavan, and Schütze set the derivation as Exercise 8.3.) Here is the plan: clear the two fractions in the denominator of the $\alpha$ form, then divide through by $\alpha$ so that the ratio $(1 - \alpha)/\alpha = \beta^2$ appears.
Put the denominator over the common denominator $PR$:
$$\alpha \frac{1}{P} + (1 - \alpha)\frac{1}{R} = \frac{\alpha R + (1 - \alpha) P}{PR}, \qquad \text{so} \qquad F = \frac{PR}{\alpha R + (1 - \alpha) P}.$$
Divide the numerator and the denominator by $\alpha$, and write $\beta^2$ for $(1 - \alpha)/\alpha$:
$$F = \frac{PR/\alpha}{R + \dfrac{1 - \alpha}{\alpha} P} = \frac{PR/\alpha}{\beta^2 P + R}.$$
Finally, $1/\alpha = (\alpha + 1 - \alpha)/\alpha = 1 + \beta^2$, which gives
$$F = \frac{(\beta^2 + 1)\,PR}{\beta^2 P + R} = F_\beta.$$
Every step is reversible, so the two expressions are the same function. At $\alpha = 0$ the $\alpha$ form is simply $R$, and $\beta^2$ is infinite; the $\beta$ form tends to $R$ as $\beta$ grows, so the correspondence holds there as a limit. At $\alpha = 1$, $\beta = 0$ and both forms equal $P$.
The numbers agree. For the example system, $\alpha = 0.2$ gives $\beta = 2$, and the $\alpha$ form is $1/(0.2/0.4 + 0.8/0.8) = 1/1.5 = 0.667$. The $\beta$ form with $\beta = 2$ is $5(0.4)(0.8)/(4(0.4) + 0.8) = 1.6/2.4 = 0.667$. The script confirms the agreement at $\alpha = 0.2$, $0.5$ and $0.8$, and on a grid of 400 pairs $(P, R)$ for four values of $\beta$.
With $\beta = 1$, equivalently $\alpha = 1/2$, the two count equally, giving the balanced F measure
$$F_1 = \frac{2 P R}{P + R}.$$
Values of $\beta < 1$ emphasize precision, and $\beta > 1$ emphasize recall. For the example system:
| Measure | Value |
|---|---|
| $F_1$ | $2(0.4)(0.8)/(0.4 + 0.8) = 0.533$ |
| $F_{0.5}$ (precision emphasized) | 0.444 |
| $F_2$ (recall emphasized) | 0.667 |
The system's strength is recall, so it scores higher when recall is emphasized.
Example (the thesis student's two queries). $F_1$ prefers the OR query. The AND query has $P = 0.50$, $R = 0.33$; the OR query has $P = 0.40$, $R = 0.67$. The OR query's $F_1$ is $2(0.4)(0.667)/(0.4 + 0.667) = 0.500$, against $2(0.5)(0.333)/(0.5 + 0.333) = 0.400$ for AND. OR gave up a little precision for a large gain in recall. A reader who weights precision more heavily reaches the opposite verdict: under $F_{0.5}$, AND scores 0.455 and OR 0.435. That is what the weight is for.
F in terms of counts
Substituting $P = TP/(TP + FP)$ and $R = TP/(TP + FN)$ gives a form that uses the contingency table directly. The reciprocals are the simplest route, since $1/P = (TP + FP)/TP$ and $1/R = (TP + FN)/TP$ share a denominator. From the $\beta$ form, dividing the numerator and the denominator by $PR$,
$$F_\beta = \frac{\beta^2 + 1}{\beta^2 \dfrac{1}{R} + \dfrac{1}{P}} = \frac{\beta^2 + 1}{\dfrac{\beta^2 (TP + FN) + (TP + FP)}{TP}} = \frac{(1 + \beta^2)\,TP}{(1 + \beta^2)\,TP + \beta^2 FN + FP}.$$
The last step multiplies through by $TP$ and collects the two $TP$ terms. With $\beta = 1$ this is
$$F_1 = \frac{2\,TP}{2\,TP + FP + FN}.$$
The derivation assumes $TP > 0$. When $TP = 0$, precision and recall are both zero (or undefined, if nothing was retrieved or nothing is relevant), the harmonic mean is undefined, and the count form gives the conventional value $F = 0$ as long as its denominator is not zero.
For the example, $F_1 = 32/(32 + 24 + 4) = 32/60 = 0.533$, and $F_2 = 80/(80 + 16 + 24) = 0.667$. This form makes two things plain.
- The true negatives do not appear. F inherits the indifference to TN that makes precision and recall suitable for retrieval.
- $\beta^2$ is the price of a missed relevant document relative to a retrieved nonrelevant one. $F_2$ counts each false negative four times as heavily as a false positive; $F_{0.5}$ counts it a quarter as much.
What β means
Van Rijsbergen (1979, ch. 7) introduced the measure as an effectiveness measure
$$E = 1 - \frac{1}{\alpha \dfrac{1}{P} + (1 - \alpha) \dfrac{1}{R}} = 1 - F,$$
so that $E$ is 0 for a perfect result and 1 for a useless one, and F is its complement. With equal weights, $E$ has a direct reading in terms of sets. Write $A$ for the set of relevant documents and $B$ for the retrieved set, so that $TP = \lvert A \cap B \rvert$, $TP + FN = \lvert A \rvert$ and $TP + FP = \lvert B \rvert$. The count form of $F_1$ is then $2\lvert A \cap B\rvert/(\lvert A \rvert + \lvert B \rvert)$, and
$$E = 1 - \frac{2\,\lvert A \cap B \rvert}{\lvert A \rvert + \lvert B \rvert} = \frac{\lvert A \rvert + \lvert B \rvert - 2\,\lvert A \cap B \rvert}{\lvert A \rvert + \lvert B \rvert} = \frac{\lvert A \,\triangle\, B \rvert}{\lvert A \rvert + \lvert B \rvert},$$
where $A \triangle B$ is the symmetric difference: the documents in exactly one of the two sets, which are the false negatives and the false positives. The last equality holds because $\lvert A \rvert + \lvert B \rvert$ counts each document of the intersection twice. So $E$ with equal weights is the number of errors of both kinds, divided by the combined size of the two sets. For the example system, $E = (4 + 24)/(20 + 40) = 0.467 = 1 - 0.533$.
Van Rijsbergen chose $\beta$ to express how many times as much the user values recall as precision. Here is the plan of the argument. We ask where a small gain in precision is worth exactly as much to $F_\beta$ as an equal gain in recall, and find that it happens where recall is $\beta$ times precision.
The formal version. Write $F_\beta = N/D$ with $N = (1 + \beta^2) P R$ and $D = \beta^2 P + R$, and apply the quotient rule to each argument in turn. With respect to $P$, $\partial N/\partial P = (1 + \beta^2) R$ and $\partial D/\partial P = \beta^2$, so
$$\frac{\partial F_\beta}{\partial P} = \frac{(1 + \beta^2) R\,(\beta^2 P + R) - (1 + \beta^2) P R\, \beta^2}{(\beta^2 P + R)^2} = \frac{(1 + \beta^2) R^2}{(\beta^2 P + R)^2},$$
because the two terms in $\beta^2 P R$ cancel. With respect to $R$, $\partial N/\partial R = (1 + \beta^2) P$ and $\partial D/\partial R = 1$, so
$$\frac{\partial F_\beta}{\partial R} = \frac{(1 + \beta^2) P\,(\beta^2 P + R) - (1 + \beta^2) P R}{(\beta^2 P + R)^2} = \frac{(1 + \beta^2) \beta^2 P^2}{(\beta^2 P + R)^2},$$
because the two terms in $PR$ cancel.
The two are equal exactly when $R^2 = \beta^2 P^2$, that is, when $R/P = \beta$. On that line, a small gain in precision is worth the same as an equal gain in recall. Below it, where recall is less than $\beta$ times precision, improving recall raises $F_\beta$ more. Above it, improving precision does. So $\beta$ is the ratio of recall to precision at which the user is indifferent between improving one or the other.
This is our derivation, checked numerically: at $P = 0.3$ the two derivatives agree at $R = 0.15$, $0.3$, and $0.6$ for $\beta = 0.5$, $1$, and $2$. Van Rijsbergen defines the user's relative importance as the ratio at which the two partial derivatives are equal. The online text of his chapter, however, writes that ratio as $P/R = \beta$. With $\alpha = 1/(\beta^2 + 1)$ the derivatives above are equal at $R/P = \beta$ instead.
Why a harmonic mean
A common first reaction is that a plain average of precision and recall would do. It would be easy to game. Retrieving every document gives $P = 0.002$ and $R = 1$, whose arithmetic mean is 0.501. That is almost as good as a system with precision and recall both at 0.5, while being useless.
The harmonic mean is dominated by the smaller of the two values: for the retrieve-everything system, $F_1 = 0.004$. A high harmonic mean requires both precision and recall to be reasonably high, which matches what makes a retrieved set useful. More generally, the harmonic mean is always at most the geometric mean, which is at most the arithmetic mean, with equality only when $P = R$. The harmonic mean penalizes imbalance most severely of the three (Manning, Raghavan, and Schütze, 2008, §8.3).
Proof of the ordering. Let $P$ and $R$ be positive. A square is never negative, so $(\sqrt{P} - \sqrt{R})^2 \ge 0$. Expanding, $P + R - 2\sqrt{PR} \ge 0$, that is,
$$\sqrt{PR} \le \frac{P + R}{2}:$$
the geometric mean is at most the arithmetic mean, with equality exactly when $\sqrt{P} = \sqrt{R}$, that is, when $P = R$. For the harmonic mean, note that
$$\frac{2PR}{P + R} = \frac{(\sqrt{PR})^2}{(P + R)/2},$$
the square of the geometric mean divided by the arithmetic mean. Dividing the geometric mean by something at least as large as itself gives at most 1, so the harmonic mean is the geometric mean times a factor $\sqrt{PR}/((P + R)/2) \le 1$. Hence it is at most the geometric mean, again with equality exactly when $P = R$. The identity also says that the geometric mean of $P$ and $R$ is the geometric mean of their arithmetic and harmonic means: in the first row of the table below, $0.566^2 = 0.320 = 0.600 \times 0.533$.
The three means for a few systems show the pattern:
| System | $P$ | $R$ | Arithmetic | Geometric | Harmonic ($F_1$) |
|---|---|---|---|---|---|
| The example | 0.400 | 0.800 | 0.600 | 0.566 | 0.533 |
| Balanced | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 |
| Retrieve everything | 0.002 | 1.000 | 0.501 | 0.045 | 0.004 |
| One result, relevant, of 20 | 1.000 | 0.050 | 0.525 | 0.224 | 0.095 |
| Lopsided | 0.900 | 0.100 | 0.500 | 0.300 | 0.180 |
When $P$ and $R$ are close, the three means barely differ. When they are far apart, the arithmetic mean stays near the average of the two, while the harmonic mean stays near the smaller. The fourth row is the precision-side counterpart of retrieving everything. A system that returns a single relevant document has perfect precision, and it scores better than the balanced system on the arithmetic mean.
The geometry of the means
The difference is clearest as geometry. Every system is a point in the square of possible precision and recall values, and a measure assigns a value to each point. Its contours, the curves along which the measure is constant, show which systems it treats as equivalent.
The arithmetic mean's contours are straight lines of slope −1: a unit of precision can always be traded for a unit of recall, wherever the system is. The $F_1$ contours bend. To find their shape, solve $F_1 = c$ for recall. From $2PR/(P + R) = c$, multiplying out gives $2PR = cP + cR$, so $R\,(2P - c) = cP$ and
$$R = \frac{cP}{2P - c} \qquad (P > c/2).$$
This is a hyperbola. As $P$ falls toward $c/2$ the denominator goes to zero and $R$ grows without bound, so $P = c/2$ is an asymptote. As $P$ grows, $R = c/(2 - c/P)$ tends to $c/2$, the other asymptote. At $P = 1$ the formula gives $R = c/(2 - c)$, and by symmetry $P = c/(2 - c)$ at $R = 1$. To reach $F_1 = 0.5$, a system needs recall of at least $0.5/1.5 = 1/3$ even with perfect precision, and precision of at least 1/3 even with perfect recall. No amount of one compensates for too little of the other. Along the diagonal $P = R$, every mean equals the common value, which is why the contours of all three cross the diagonal at the same places.
Weighting moves the asymptotes. The same steps applied to $F_\beta = c$ give $(1 + \beta^2) P R = c\beta^2 P + cR$, so $R\,((1 + \beta^2) P - c) = c \beta^2 P$ and
$$R = \frac{c\beta^2 P}{(1 + \beta^2) P - c},$$
a hyperbola with asymptotes $P = c/(1 + \beta^2)$, where the denominator vanishes, and $R = c\beta^2/(1 + \beta^2)$, the limit for large $P$. For $F_2 = 0.5$ these are $P = 0.5/5 = 0.1$ and $R = 0.5 \times 4/5 = 0.4$. Inside the square, the contour runs from $P = 1/6$ at perfect recall (set $R = 1$: $5P = 2P + 0.5$) to $R = 2/4.5 = 4/9 \approx 0.444$ at perfect precision (set $P = 1$). So a system can reach $F_2 = 0.5$ with poor precision, but not with poor recall. For $F_{0.5} = 0.5$ the roles swap.
Each contour bends most sharply at its vertex, which lies exactly on the line $R = \beta P$ where the two derivatives are equal. To see it, write the contour as $(P - a)(R - b) = ab$ with $a = c/(1 + \beta^2)$ and $b = c\beta^2/(1 + \beta^2)$. (Expanding the product gives $PR = bP + aR$, which is the equation $(1 + \beta^2) PR = c\beta^2 P + cR$ divided by $1 + \beta^2$.) The asymptotes cross at $(a, b)$, and the vertex is the point of the curve nearest that crossing. With $u = P - a$ and $v = R - b$, the curve is $uv = ab$, and the squared distance is $u^2 + v^2 = (u - v)^2 + 2uv = (u - v)^2 + 2ab$, which is smallest when $u = v = \sqrt{ab}$. So the vertex is at $P = a + \sqrt{ab}$, $R = b + \sqrt{ab}$. Its ratio is
$$\frac{R}{P} = \frac{b + \sqrt{ab}}{a + \sqrt{ab}} = \frac{\sqrt{b}\,(\sqrt{b} + \sqrt{a})}{\sqrt{a}\,(\sqrt{a} + \sqrt{b})} = \sqrt{\frac{b}{a}} = \beta.$$
Averaging over queries
Precision, recall, and F are computed for one query, and there are two ways to combine them across a test collection.
- A macro-average computes the measure for each query and takes the mean, so every query counts equally.
- A micro-average pools the contingency tables of all queries into one and computes the measure from the totals. Every document decision counts equally, and queries with many relevant documents dominate.
Manning, Raghavan, and Schütze (2008, §13.6) describe the same distinction for text classification.
Suppose a second query retrieves 10 documents, 1 of them relevant, out of 2 relevant documents in the collection. The micro-average of the two queries resembles the first, larger one:
| TP | FP | FN | $P$ | $R$ | $F_1$ | |
|---|---|---|---|---|---|---|
| Query A (the example) | 16 | 24 | 4 | 0.400 | 0.800 | 0.533 |
| Query B | 1 | 9 | 1 | 0.100 | 0.500 | 0.167 |
| Macro-average (mean of rows) | 0.250 | 0.650 | 0.350 | |||
| Micro-average (pooled counts) | 17 | 33 | 5 | 0.340 | 0.773 | 0.472 |
The micro-average is close to query A's values, because A contributes 16 of the 17 true positives. There is also a third number that is sometimes reported: $F_1$ computed from the macro-averaged precision and recall. It is $2(0.25)(0.65)/(0.25 + 0.65) = 0.361$, which is neither the mean $F_1$ (0.350) nor the micro $F_1$.
Retrieval evaluation macro-averages by convention, because each information need is taken to matter equally, and mean average precision is a macro-average. A reported F should state which of these it is.
Common mistakes
- Treating precision and recall as symmetric. They are not interchangeable. Precision is under the system's control and can be measured from the retrieved documents alone. Recall depends on documents nobody has looked at, and is only an estimate when judgments are incomplete.
- Reporting the F of averages as the average of Fs. As the table above shows, $F_1$ of the mean precision and mean recall differs from the mean $F_1$.
- Comparing F values with different β. $F_1 = 0.533$ and $F_2 = 0.667$ describe the same system. A higher number under a different weighting is not an improvement.
- Using F for a ranking. F needs a set, so applying it to a ranking needs a cutoff, and the choice of cutoff can matter more than the system. The measures in evaluating ranked results avoid the choice by looking at every cutoff at once.
Worked problems
Problems 1 to 3 are exercises of the course text (Manning, Raghavan, and Schütze, 2008, Exercises 8.1, 8.2 and 8.7), restated here with solutions in our own words. Exercise 8.3, the equivalence of the two forms of F, is proved in full in the section on the definition above. Problems 4 and 5 are posed on this article's own examples. The numbers are recomputed in tools/experiments/eval_measures/worked_examples.py.
Problem 1 (Exercise 8.1). A system returns 8 relevant documents and 10 nonrelevant documents. The collection holds 20 relevant documents in all. Find the precision and the recall of the search.
Solution. Precision is $8/18 = 0.444$ and recall is $8/20 = 0.400$. The system retrieved $8 + 10 = 18$ documents, so $TP = 8$ and $FP = 10$, and precision is $TP/(TP + FP) = 8/18$. Of the 20 relevant documents it found 8, so $FN = 12$ and recall is $TP/(TP + FN) = 8/20$. The size of the collection is not given and is not needed, because neither measure uses the true negatives. For completeness, $F_1 = 2\,TP/(2\,TP + FP + FN) = 16/38 = 0.421$.
Problem 2 (Exercise 8.2). $F_1$ is the harmonic mean of precision and recall. State the advantage of the harmonic mean over the arithmetic mean.
Solution. The harmonic mean cannot be made large by making one of the two measures large at the expense of the other, and the arithmetic mean can. A system can always reach recall 1 by retrieving the whole collection. Its precision is then the share of the collection that is relevant, 0.002 in this article's example, and its arithmetic mean is $(0.002 + 1)/2 = 0.501$, the score of a system with precision and recall both at one half. Its harmonic mean is $2(0.002)(1)/(1.002) = 0.004$. In general the harmonic mean is at most twice the smaller of the two values, since $2PR/(P + R) \le 2PR/R = 2P$ and likewise $\le 2R$, while the arithmetic mean is at least half the larger. The inequality proved above places the harmonic mean below the geometric and the arithmetic means whenever $P \ne R$, so it is the most severe of the three on an unbalanced result.
Problem 3 (Exercise 8.7). The Dice coefficient of two sets is $\text{Dice}(X, Y) = 2\lvert X \cap Y \rvert / (\lvert X \rvert + \lvert Y \rvert)$. Show that $F_1$ equals the Dice coefficient of the retrieved set and the relevant set.
Solution. Let $X$ be the retrieved set and $Y$ the relevant set. The documents in both are the true positives, so $\lvert X \cap Y \rvert = TP$. The retrieved set consists of the true and the false positives, so $\lvert X \rvert = TP + FP$, and the relevant set of the true positives and the false negatives, so $\lvert Y \rvert = TP + FN$. Therefore
$$\text{Dice}(X, Y) = \frac{2\,TP}{(TP + FP) + (TP + FN)} = \frac{2\,TP}{2\,TP + FP + FN} = F_1,$$
by the count form derived above. For the example system, $2 \times 16/(40 + 20) = 32/60 = 0.533$. The complement, $1 - \text{Dice}$, is van Rijsbergen's $E$ with equal weights, the normalized symmetric difference.
Problem 4 (the Cranfield sweep, in counts). In the table for Cranfield query 2, the top 9 results hold 5 of the 24 relevant documents. Compute $F_1$ from the contingency table without computing precision or recall, and explain why $F_1$ falls at $k = 10$.
Solution. $F_1 = 10/33 = 0.303$ at $k = 9$, and $10/34 = 0.294$ at $k = 10$. At $k = 9$ the counts are $TP = 5$, $FP = 9 - 5 = 4$ and $FN = 24 - 5 = 19$, so $F_1 = 2 \times 5/(2 \times 5 + 4 + 19) = 10/33$. The tenth result is not relevant. It leaves $TP$ and $FN$ unchanged and raises $FP$ to 5, so the denominator grows by one and $F_1 = 10/34$. In the count form a nonrelevant document always lowers $F_1$, and a relevant one always raises it: it moves a document from $FN$ to $TP$, turning $2\,TP/(2\,TP + FP + FN)$ into $(2\,TP + 2)/(2\,TP + 1 + FP + FN)$, which is larger because the numerator grows by more than the denominator and the fraction is below 1.
Problem 5 (the weight at which the student's two queries tie). The AND query has $TP = 1$, $FP = 1$, $FN = 2$ and the OR query has $TP = 2$, $FP = 3$, $FN = 1$. Find every $\beta$ for which $F_\beta$ scores them equally, and say which query each other $\beta$ prefers.
Solution. They tie at $\beta = 1/\sqrt{3} = 0.577$ only; a smaller $\beta$ prefers AND and a larger one prefers OR. Write $b = \beta^2$. The count form gives
$$F_\beta(\text{AND}) = \frac{(1 + b)}{(1 + b) + 2b + 1} = \frac{1 + b}{2 + 3b}, \qquad F_\beta(\text{OR}) = \frac{2(1 + b)}{2(1 + b) + b + 3} = \frac{2(1 + b)}{5 + 3b}.$$
Since $1 + b > 0$, the two are equal exactly when $1/(2 + 3b) = 2/(5 + 3b)$, that is, $5 + 3b = 4 + 6b$, so $b = 1/3$. At that weight both equal $(4/3)/3 = 4/9 = 0.444$. AND scores higher exactly when $5 + 3b > 4 + 6b$, that is, when $b < 1/3$. This agrees with the values in the example above: at $\beta = 0.5$ ($b = 0.25$) AND leads, 0.455 to 0.435, and at $\beta = 1$ OR leads, 0.500 to 0.400. Only a weighting with $\beta$ below 0.577 prefers the AND result.
What we have learned
Precision and recall read a retrieved set from two sides: how much of what was shown is relevant, and how much of what is relevant was shown. Both ignore the true negatives, which is why they suit retrieval where accuracy fails. They trade against each other. The F measure combines them as a harmonic mean, so neither can be neglected, and its $\beta$ is the recall-to-precision ratio at which a user is indifferent between gains in either.
All of this evaluates a set. Most systems return a ranking, whose quality depends on where the relevant documents appear. Computing precision and recall at every cutoff, and summarizing the result, is the subject of the next article, Evaluating Ranked Results.
References
- Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, sections 8.3 and 13.6. Cambridge University Press. record · 102 pages
- van Rijsbergen, C. J. (1979). Information Retrieval, 2nd edition, chapter 7. Butterworths. record · 8 pages
Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 6 revisions