Precision and recall
Imagine a world where computers are constantly trying to understand and classify everything around us—from identifying spam emails to spotting diseases in medical scans. How do we know if they're doing a good job? That's where 'precision' and 'recall' come in, two vital metrics that help us evaluate just how smart our smart systems really are, especially when the stakes are high. Precision measures the accuracy of a system's positive predictions, telling us how many of the identified items are actually correct. Recall measures a system's ability to find all relevant items, revealing how many of the actual correct items were successfully identified. Balancing precision and recall often involves a critical trade-off, where the 'better' metric depends heavily on the real-world costs associated with different types of errors.
AI Summary
Imagine a world where computers are constantly trying to understand and classify everything around us—from identifying spam emails to spotting diseases in medical scans. How do we know if they're doing a good job? That's where 'precision' and 'recall' come in, two vital metrics that help us evaluate just how smart our smart systems really are, especially when the stakes are high.
- Precision measures the accuracy of a system's positive predictions, telling us how many of the identified items are actually correct.
- Recall measures a system's ability to find all relevant items, revealing how many of the actual correct items were successfully identified.
- Balancing precision and recall often involves a critical trade-off, where the 'better' metric depends heavily on the real-world costs associated with different types of errors.
Evaluating Smart Systems
In fields like machine learning, object detection, or information retrieval, we often ask systems to find specific things within vast amounts of data. Whether it's finding relevant documents, spotting a dog in a photo, or identifying a medical condition, we need a way to gauge their performance. This is where precision and recall become indispensable tools.
The Dog Detection Dilemma
Let's imagine a computer program designed to recognize dogs in photographs. We feed it a picture containing ten cats and twelve dogs. The program processes it and identifies eight animals as dogs. Sounds simple enough, right? But how well did it actually do?
Understanding the Outcomes: True and False
To answer that, we categorize the program's predictions. When the program said 'dog,' was it right or wrong? And when there was a dog, did the program find it or miss it? These questions lead us to four key outcomes that form the foundation of precision and recall:
In our dog example, out of the eight identified dogs, five were actual dogs (True Positives), and three were cats (False Positives). Meanwhile, seven real dogs were missed (False Negatives), and seven cats were correctly ignored (True Negatives).
True Positives (TP): Correctly identified as positive (e.g., a real dog correctly called a dog). False Positives (FP): Incorrectly identified as positive (e.g., a cat incorrectly called a dog). False Negatives (FN): Incorrectly identified as negative (e.g., a real dog missed by the program). True Negatives (TN): Correctly identified as negative (e.g., a cat correctly not called a dog).
Precision: How Accurate Were the Positives?
Precision answers the question: 'Of all the things the system said were positive, how many actually were?' It measures the quality or exactness of the positive predictions. A high precision means the system makes very few false alarms.
For our dog detection program, the precision is 5 (True Positives) divided by 5 (True Positives) + 3 (False Positives), which equals 5/8, or 62.5%. This means 62.5% of the animals the program identified as dogs were indeed dogs.
\text{Precision} = \frac{\text{True Positives}}{\text{True Positives} + \text{False Positives}}Recall: How Many Relevant Items Were Found?
Recall, also known as sensitivity, asks: 'Of all the things that should have been identified as positive, how many did the system actually find?' It measures the completeness of the positive predictions—how good the system is at catching all the relevant cases.
In our dog scenario, the recall is 5 (True Positives) divided by 5 (True Positives) + 7 (False Negatives), which equals 5/12, or approximately 41.7%. This means the program only found about 41.7% of all the actual dogs in the picture.
\text{Recall} = \frac{\text{True Positives}}{\text{True Positives} + \text{False Negatives}}The Crucial Trade-Off
Precision and recall are rarely useful in isolation, and often, there's an inverse relationship between them. You can achieve perfect recall by just classifying everything as positive—but then your precision would likely be terrible. Conversely, you can achieve perfect precision by only picking one single, absolutely certain positive—but then you'd miss almost everything else, leading to terrible recall.
Smoke Detectors vs. Criminal Justice
Consider a smoke detector. Its primary goal is to catch every fire. It's designed for high recall, even if it means many false alarms (False Positives) from burnt toast. The cost of a False Negative (missing a real fire) is prohibitively high. The criminal justice system, on the other hand, often prioritizes precision. The idea that 'it is better that ten guilty persons escape than that one innocent suffer' emphasizes avoiding False Positives (convicting an innocent person), even if it means some guilty people (False Negatives) go free. This illustrates how the value placed on precision or recall depends entirely on the context and the consequences of different errors.
The Brain Surgeon's Dilemma
Imagine a surgeon removing a cancerous brain tumor. They need to remove all tumor cells to prevent regrowth (high recall). But they must not remove healthy brain cells, which would cause permanent damage (high precision). These competing goals force a difficult decision. Being more aggressive increases recall but risks precision. Being more conservative increases precision but risks recall. It's a vivid illustration of the delicate balance.
Beyond Simple Accuracy
Many people default to 'accuracy' as a metric. Accuracy is simply the proportion of correct predictions (True Positives + True Negatives) out of all predictions. While it seems straightforward, accuracy can be deeply misleading, especially with imbalanced datasets.
Think of a system detecting a rare disease that affects only 1% of the population. If the system simply predicts 'no disease' for everyone, it would still achieve 99% accuracy! But it would have missed every single actual case (0% recall), making it useless for its purpose. Precision and recall help us see past such deceptive numbers.
\text{Accuracy} = \frac{\text{True Positives} + \text{True Negatives}}{\text{True Positives} + \text{True Negatives} + \text{False Positives} + \text{False Negatives}}Combining Them: The F-Measure
Because precision and recall are often intertwined, researchers frequently use a single metric that combines them: the F-measure, or F-score. The most common is the F1-score, which is the harmonic mean of precision and recall, giving them equal weight.
The harmonic mean is particularly useful because it heavily penalizes extreme values. If either precision or recall is very low, the F1-score will also be low, forcing a balance between the two.
F_1 = 2 \cdot \frac{\text{Precision} \cdot \text{Recall}}{\text{Precision} + \text{Recall}}However, sometimes we want to prioritize one over the other. That's where the generalized F-beta measure comes in. The 'beta' parameter allows us to weight recall (when beta > 1) or precision (when beta < 1) more heavily. For example, F2-score weights recall twice as much as precision, while F0.5-score weights precision twice as much as recall.
This flexibility makes the F-measure incredibly powerful for tailoring evaluation to specific application needs, ensuring that the 'best' system isn't just accurate, but also aligns with what truly matters in its real-world function.
F_{\beta} = (1 + \beta^2) \cdot \frac{\text{Precision} \cdot \text{Recall}}{(\beta^2 \cdot \text{Precision}) + \text{Recall}}Beyond Binary: Multi-Class Evaluation
Precision and recall aren't just for problems with two outcomes, like 'dog' or 'not-dog.' They can be extended to multi-class classification, where there are many possible categories. To do this, we calculate precision and recall for each class individually, treating it as the 'positive' class and all others as 'negative'.
These class-wise scores can then be combined into overall metrics, often using methods like 'macro F1,' which averages the F1-scores of each class. This provides a comprehensive view of how well a system performs across all categories it's designed to identify.
Article
Precision and recall
Precision and recall
In classification, precision and recall are performance metrics that apply to data retrieved from a collection, corpus or sample space.
Precision (also called positive predictive value) is the fraction of relevant instances among the retrieved instances. Written as a formula:
${\displaystyle {\text{Precision}}={\frac {\text{Relevant retrieved instances}}{{\text{All }}{\textbf {retrieved}}{\text{ instances}}}}}$
Recall (also known as sensitivity) is the fraction of relevant instances that were retrieved. Written as a formula:
${\displaystyle {\text{Recall}}={\frac {\text{Relevant retrieved instances}}{{\text{All }}{\textbf {relevant}}{\text{ instances}}}}}$
Both precision and recall are therefore based on relevance.
Consider a computer program for recognizing dogs (the relevant element) in a digital photograph. Upon processing a picture which contains ten cats and twelve dogs, the program identifies eight dogs. Of the eight elements identified as dogs, only five actually are dogs (true positives), while the other three are cats (false positives). Seven dogs were missed (false negatives), and seven cats were correctly excluded (true negatives). The program's precision is then 5/8 (true positives / selected elements) while its recall is 5/12 (true positives / relevant elements).
Adopting a hypothesis-testing approach, where in this case, the null hypothesis is that a given item is irrelevant (not a dog), absence of type I and type II errors (perfect specificity and sensitivity) corresponds respectively to perfect precision (no false positives) and perfect recall (no false negatives).
More generally, recall is simply the complement of the type II error rate (i.e., one minus the type II error rate). Precision is related to the type I error rate, but in a slightly more complicated way, as it also depends upon the prior distribution of seeing a relevant vs. an irrelevant item.
The above cat and dog example contained 8 − 5 = 3 type I errors (false positives) out of 10 total cats (true negatives), for a type I error rate of 3/10, and 12 − 5 = 7 type II errors (false negatives), for a type II error rate of 7/12. Precision can be seen as a measure of quality, and recall as a measure of quantity. Higher precision means that an algorithm returns more relevant results than irrelevant ones, and high recall means that an algorithm returns most of the relevant results (whether or not irrelevant ones are also returned).
Introduction
Precision and recall
A dog classifier example. This classifier successfully identified 5 images as containing a dog, but misidentified 3 cats as being dogs.
In a classification task, the precision for a class is the number of true positives (i.e. the number of items correctly labelled as belonging to the positive class) divided by the total number of elements labelled as belonging to the positive class (i.e. the sum of true positives and false positives, which are items incorrectly labelled as belonging to the class). Recall in this context is defined as the number of true positives divided by the total number of elements that actually belong to the positive class (i.e. the sum of true positives and false negatives, which are items which were not labelled as belonging to the positive class but should have been).
Precision and recall are not particularly useful metrics when used in isolation. For instance, it is possible to have perfect recall by simply retrieving every single item. Likewise, it is possible to achieve perfect precision by selecting only a very small number of extremely likely items.
In a classification task, a precision score of 1.0 for a class C means that every item labelled as belonging to class C does indeed belong to class C (but says nothing about the number of items from class C that were not labelled correctly) whereas a recall of 1.0 means that every item from class C was labelled as belonging to class C (but says nothing about how many items from other classes were incorrectly also labelled as belonging to class C).
Often, there is an inverse relationship between precision and recall, where it is possible to increase one at the cost of reducing the other, but context may dictate if one is more valued in a given situation:
A smoke detector is generally designed to commit many Type I errors (to alert in many situations when there is no danger), because the cost of a Type II error (failing to sound an alarm during a major fire) is prohibitively high. As such, smoke detectors are designed with recall in mind (to catch all real danger), even while giving little weight to the losses in precision (and making many false alarms). In the other direction, Blackstone's ratio, "It is better that ten guilty persons escape than that one innocent suffer," emphasizes the costs of a Type I error (convicting an innocent person). As such, the criminal justice system is geared toward precision (not convicting innocents), even at the cost of losses in recall (letting more guilty people go free).
A brain surgeon removing a cancerous tumor from a patient's brain illustrates the tradeoffs as well: The surgeon needs to remove all of the tumor cells since any remaining cancer cells will regenerate the tumor. Conversely, the surgeon must not remove healthy brain cells since that would leave the patient with impaired brain function. The surgeon may be more liberal in the area of the brain they remove to ensure they have extracted all the cancer cells. This decision increases recall but reduces precision. On the other hand, the surgeon may be more conservative in the brain cells they remove to ensure they extract only cancer cells. This decision increases precision but reduces recall. That is to say, greater recall increases the chances of removing healthy cells (negative outcome) and increases the chances of removing all cancer cells (positive outcome). Greater precision decreases the chances of removing healthy cells (positive outcome) but also decreases the chances of removing all cancer cells (negative outcome).
Usually, precision and recall scores are not discussed in isolation. A precision-recall curve plots precision as a function of recall; usually precision will decrease as the recall increases. Alternatively, values for one measure can be compared for a fixed level at the other measure (e.g. precision at a recall level of 0.75) or both are combined into a single measure. Examples of measures that are a combination of precision and recall are the F-measure (the weighted harmonic mean of precision and recall), or the Matthews correlation coefficient, which is a geometric mean of the chance-corrected variants: the regression coefficients Informedness (DeltaP') and Markedness (DeltaP). Accuracy is a weighted arithmetic mean of Precision and Inverse Precision (weighted by Bias) as well as a weighted arithmetic mean of Recall and Inverse Recall (weighted by Prevalence). Inverse Precision and Inverse Recall are simply the Precision and Recall of the inverse problem where positive and negative labels are exchanged (for both real classes and prediction labels). True Positive Rate and False Positive Rate, or equivalently Recall and 1 - Inverse Recall, are frequently plotted against each other as ROC curves and provide a principled mechanism to explore operating point tradeoffs. Outside of Information Retrieval, the application of Recall, Precision and F-measure are argued to be flawed as they ignore the true negative cell of the contingency table, and they are easily manipulated by biasing the predictions. The first problem is 'solved' by using Accuracy and the second problem is 'solved' by discounting the chance component and renormalizing to Cohen's kappa, but this no longer affords the opportunity to explore tradeoffs graphically. However, Informedness and Markedness are Kappa-like renormalizations of Recall and Precision, and their geometric mean Matthews correlation coefficient thus acts like a debiased F-measure.
Definition
Precision and recall
For classification tasks, the terms true positives, true negatives, false positives, and false negatives compare the results of the classifier under test with trusted external judgments. The terms positive and negative refer to the classifier's prediction (sometimes known as the expectation), and the terms true and false refer to whether that prediction corresponds to the external judgment (sometimes known as the observation).
Let us define an experiment from P positive instances and N negative instances for some condition. The four outcomes can be formulated in a 2×2 contingency table or confusion matrix, as follows:
<table><thead><tr><th rowspan="2"></th><th></th><th colspan="2">Predicted condition</th><th colspan="2">Sources:</th></tr></thead><tbody><tr><td>Total population = P + N</td><td>Predicted positive</td><td>Predicted negative</td><td>Informedness, bookmaker informedness (BM) = TPR + TNR − 1</td><td>Prevalence threshold (PT) = √TPR × FPR − FPR/TPR − FPR</td></tr><tr><td rowspan="2">Actual condition</td><td>Real Positive (P)</td><td>True positive (TP), hit</td><td>False negative (FN), miss, underestimation</td><td>True positive rate (TPR), recall, sensitivity (SEN), probability of detection, hit rate, power = TP/P = 1 − FNR</td><td>False negative rate (FNR), miss rate type II error = FN/P = 1 − TPR</td></tr><tr><td>Real Negative (N)</td><td>False positive (FP), false alarm, overestimation</td><td>True negative (TN), correct rejection</td><td>False positive rate (FPR), probability of false alarm, fall-out type I error = FP/N = 1 − TNR</td><td>True negative rate (TNR), specificity (SPC), selectivity = TN/N = 1 − FPR</td></tr><tr><td rowspan="3"></td><td>Prevalence = P/P + N</td><td>Positive predictive value (PPV), precision = TP/TP + FP = 1 − FDR</td><td>False omission rate (FOR) = FN/TN + FN = 1 − NPV</td><td>Positive likelihood ratio (LR+) = TPR/FPR</td><td>Negative likelihood ratio (LR−) = FNR/TNR</td></tr><tr><td>Accuracy (ACC) = TP + TN/P + N</td><td>False discovery rate (FDR) = FP/TP + FP = 1 − PPV</td><td>Negative predictive value (NPV) = TN/TN + FN = 1 − FOR</td><td>Markedness (MK), deltaP (Δp) = PPV + NPV − 1</td><td>Diagnostic odds ratio (DOR) = LR+/LR− = TP × TN/FP × FN</td></tr><tr><td>Balanced accuracy (BA) = TPR + TNR/2</td><td>F1 score = 2 PPV × TPR/PPV + TPR = 2 TP/2 TP + FP + FN</td><td>Fowlkes–Mallows index (FM) = √PPV × TPR</td><td>phi or Matthews correlation coefficient (MCC) = √TPR × TNR × PPV × NPV - √FNR × FPR × FOR × FDR</td><td colspan="2">Threat score (TS), critical success index (CSI), Jaccard index = TP/TP + FN + FP</td></tr></tbody></table>
${\displaystyle {\begin{aligned}{\text{Precision}}&={\frac {tp}{tp+fp}}\\{\text{Recall}}&={\frac {tp}{tp+fn}}\,\end{aligned}}}$
Recall in this context is also referred to as the true positive rate or sensitivity, and precision is also referred to as positive predictive value (PPV); other related measures used in classification include true negative rate and accuracy. True negative rate is also called specificity.
${\displaystyle {\text{True negative rate}}={\frac {tn}{tn+fp}}\,}$
Precision vs. recall
Both precision and recall may be useful in cases where there is imbalanced data. However, it may be valuable to prioritize one metric over the other in cases where the outcome of a false positive or false negative is costly. For example, in medical diagnosis, a false positive test can lead to unnecessary treatment and expenses. In this situation, it is useful to value precision over recall. In other cases, the cost of a false negative is high, and recall may be a more valuable metric. For instance, the cost of a false negative in fraud detection is high, as failing to detect a fraudulent transaction can result in significant financial loss.
Probabilistic definition
Precision and recall can be interpreted as (estimated) conditional probabilities: Precision is given by ${\displaystyle \mathbb {P} (C=P|{\hat {C}}=P)}$ while recall is given by ${\displaystyle \mathbb {P} ({\hat {C}}=P|C=P)}$, where ${\displaystyle {\hat {C}}}$ is the predicted class and ${\displaystyle C}$ is the actual class (i.e. ${\displaystyle C=P}$ means the actual class is positive). Both quantities are, therefore, connected by Bayes' theorem.
No-skill classifiers
The probabilistic interpretation allows to easily derive how a no-skill classifier would perform. A no-skill classifier is defined by the property that the joint probability ${\displaystyle \mathbb {P} (C=P,{\hat {C}}=P)=\mathbb {P} (C=P)\mathbb {P} ({\hat {C}}=P)}$ is just the product of the unconditional probabilities since the classification and the presence of the class are independent.
For example, the precision of a no-skill classifier is simply a constant ${\displaystyle \mathbb {P} (C=P|{\hat {C}}=P)={\frac {\mathbb {P} (C=P,{\hat {C}}=P)}{\mathbb {P} ({\hat {C}}=P)}}=\mathbb {P} (C=P),}$ i.e. determined by the probability/frequency with which the class P occurs.
A similar argument can be made for the recall: ${\displaystyle \mathbb {P} ({\hat {C}}=P|C=P)={\frac {\mathbb {P} (C=P,{\hat {C}}=P)}{\mathbb {P} (C=P)}}=\mathbb {P} ({\hat {C}}=P)}$ which is the probability for a positive classification.
Accuracy, imbalanced data, and balanced accuracy
Precision and recall
${\displaystyle {\text{Accuracy}}={\frac {TP+TN}{TP+TN+FP+FN}}\,}$
Accuracy can be expressed as the weighted average of how well a classifier identifies positive cases and negative cases, weighted by the condition's base prevalence (${\textstyle P}$). This formulation relies on sensitivity (the true positive rate) and specificity (the true negative rate):
${\displaystyle {\text{Accuracy}}=(P\times {\text{Sensitivity}})+((1-P)\times {\text{Specificity}})}$
In machine learning terminology, sensitivity is equivalent to the recall of the positive class (often termed ${\textstyle recall{1}}$), while specificity is equivalent to the recall of the negative class (often termed ${\textstyle recall{0}}$). Because this equation scales the true positive and true negative rates directly by the actual number of positive and negative cases available in the dataset, it remains mathematically strictly bounded across all prevalence levels.
Alternatively, Accuracy can be expressed to depend on both precision (${\textstyle P{recision}}$), recall (${\textstyle R{ecall}}$, i.e., ${\textstyle recall{1}}$), and prevalence (${\textstyle P}$). By expressing accuracy as 1 minus the total error rate, the accuracy of a classifier is given by:
${\displaystyle {\text{Accuracy}}=1-P\left[(1-R{ecall})+R{ecall}\left({\frac {1-P{recision}}{P{recision}}}\right)\right]}$
In this form, the equation isolates how accuracy is penalized by two distinct errors scaled by prevalence: the rate at which positive cases are missed (${\textstyle {\text{FN rate}}=1-R{ecall}}$), and the rate of collateral false positives generated by catching them (${\textstyle {\text{FP rate}}=R{ecall}\left({\frac {1-P{recision}}{P{recision}}}\right)}$). This explicit relationship highlights how changes in precision and recall impact overall accuracy disproportionately depending on the underlying prevalence in an imbalanced dataset.
However, because prevalence, precision, and recall are not independent variables, this formula is strictly bound by a mathematical limit. The mathematically implied number of false positives cannot exceed the total number of actual negative cases in the dataset. Therefore, the accuracy formula above is only valid subject to the following constraint on minimum precision:
${\displaystyle P{recision}\geq {\frac {P\cdot R{ecall}}{1-P+P\cdot R{ecall}}}}$
Because of the above, Accuracy can be a limited/misleading metric when comparing data sets with different base prevalence (i.e. differently imbalanced data sets). For example, a method with 90% precision and 50% recall would yield an accuracy of either 83% or 50%, depending if the prevalence in the dataset is 30% or 90%. Also, if a sample has 95 negative and 5 positive values, then classifying all values as negative (100% recall and 0% precision) would give 0.95 accuracy score.
There are many metrics that don't suffer from this problem. For example, balanced accuracy (bACC) normalizes true positive and true negative predictions by the number of positive and negative samples, respectively, and divides their sum by two:
${\displaystyle {\text{Balanced accuracy}}={\frac {TPR+TNR}{2}}\,}$
For the previous example (95 negative and 5 positive samples), classifying all as negative gives 0.5 balanced accuracy score (the maximum bACC score is one), which is equivalent to the expected value of a random guess in a balanced data set. Balanced accuracy can serve as an overall performance metric for a model, whether or not the true labels are imbalanced in the data, assuming the cost of FN is the same as FP.
Balanced accuracy is a linear combination of Youden's J statistic. (${\displaystyle {\text{Balanced Accuracy}}={\frac {J+1}{2}}}$)
The TPR and FPR are a property of a given classifier operating at a specific threshold. However, the overall number of TPs, FPs etc. depend on the class imbalance in the data via the class ratio ${\textstyle r=P/N}$. As the recall (or TPR) depends only on positive cases, it is not affected by ${\textstyle r}$, but the precision is. We have that
${\displaystyle {\text{Precision}}={\frac {TP}{TP+FP}}={\frac {P\cdot TPR}{P\cdot TPR+N\cdot FPR}}={\frac {TPR}{TPR+{\frac {1}{r}}FPR}}.}$
Thus the precision has an explicit dependence on ${\textstyle r}$. Starting with balanced classes at ${\textstyle r=1}$ and gradually decreasing ${\textstyle r}$, the corresponding precision will decrease, because the denominator increases.
Another metric is the predicted positive condition rate (PPCR), which identifies the percentage of the total population that is flagged. For example, for a search engine that returns 30 results (retrieved documents) out of 1,000,000 documents, the PPCR is 0.003%.
${\displaystyle {\text{Predicted positive condition rate}}={\frac {TP+FP}{TP+FP+TN+FN}}\,}$
According to Saito and Rehmsmeier, precision-recall plots are more informative than ROC plots when evaluating binary classifiers on imbalanced data. In such scenarios, ROC plots may be visually deceptive with respect to conclusions about the reliability of classification performance.
Different from the above approaches, if an imbalance scaling is applied directly by weighting the confusion matrix elements, the standard metrics definitions still apply even in the case of imbalanced datasets. The weighting procedure relates the confusion matrix elements to the support set of each considered class.
F-measure
Precision and recall
A measure that combines precision and recall is the harmonic mean of precision and recall, the traditional F-measure or balanced F-score:
${\displaystyle F=2\cdot {\frac {\mathrm {precision} \cdot \mathrm {recall} }{\mathrm {precision} +\mathrm {recall} }}}$
This measure is approximately the average of the two when they are close, and is more generally the harmonic mean, which, for the case of two numbers, coincides with the square of the geometric mean divided by the arithmetic mean. There are several reasons that the F-score can be criticized, in particular circumstances, due to its bias as an evaluation metric. This is also known as the ${\displaystyle F{1}}$ measure, because recall and precision are evenly weighted.
It is a special case of the general ${\displaystyle F{\beta }}$ measure (for non-negative real values of ${\displaystyle \beta }$):
${\displaystyle F{\beta }=(1+\beta ^{2})\cdot {\frac {\mathrm {precision} \cdot \mathrm {recall} }{\beta ^{2}\cdot \mathrm {precision} +\mathrm {recall} }}}$
Two other commonly used ${\displaystyle F}$ measures are the ${\displaystyle F{2}}$ measure, which weights recall higher than precision, and the ${\displaystyle F{0.5}}$ measure, which puts more emphasis on precision than recall.
The F-measure was derived by van Rijsbergen (1979) so that ${\displaystyle F{\beta }}$ "measures the effectiveness of retrieval with respect to a user who attaches ${\displaystyle \beta }$ times as much importance to recall as precision". It is based on van Rijsbergen's effectiveness measure ${\displaystyle E{\alpha }=1-{\frac {1}{{\frac {\alpha }{P}}+{\frac {1-\alpha }{R}}}}}$, the second term being the weighted harmonic mean of precision and recall with weights ${\displaystyle (\alpha ,1-\alpha )}$. Their relationship is ${\displaystyle F{\beta }=1-E{\alpha }}$ where ${\displaystyle \alpha ={\frac {1}{1+\beta ^{2}}}}$.
Limitations as goals
Precision and recall
There are other parameters and strategies for performance metric of information retrieval system, such as the area under the ROC curve (AUC) or pseudo-R-squared.
Multi-class evaluation
Precision and recall
Precision and recall values can also be calculated for classification problems with more than two classes. To obtain the precision for a given class, we divide the number of true positives by the classifier bias towards this class (number of times that the classifier has predicted the class). To calculate the recall for a given class, we divide the number of true positives by the prevalence of this class (number of times that the class occurs in the data sample).
The class-wise precision and recall values can then be combined into an overall multi-class evaluation score, e.g., using the macro F1 metric.
Generalisation to continuous distributions
Precision and recall
The classical definitions of precision, recall, and F-score are formulated for binary classification, where each instance is either true or false. Many practical domains, however, produce inherently continuous signals rather than discrete labels. Generalising these metrics to continuous distributions enables their direct application to such data without the information loss introduced by thresholding.
Two motivating examples illustrate the limitation of binary frameworks:
• Quantitative finance. A model may output a continuous buy/sell signal proportional to its conviction for each asset at a given moment. Applying a fixed threshold (e.g. signal > 0.1 = buy) discards conviction magnitude and conflates strong and mild signals, limiting the model's ability to correctly distinguish a strong buy from a mild one. • DNA methylation analysis. Sequencing tools detect differentially methylated regions whose underlying signal is continuous, typically ranging from −1 to +1. Forcing this into a binary framework introduces similar distortions by treating all positive deviations as equivalent regardless of magnitude.
Definitions
Let ${\displaystyle x{i}}$ denote the expected (ground-truth) signal and ${\displaystyle y{i}}$ the observed (predicted) signal at each data point ${\displaystyle i}$. Then, precision, recall, and F-score can be calculated as:
${\displaystyle {\text{Precision}}={\frac {\sum {\frac {2x{i}y{i}}{x{i}^{2}+y{i}^{2}}}y{i}^{2}}{\sum y{i}^{2}}}}$
${\displaystyle {\text{Recall}}={\frac {\sum {\frac {2x{i}y{i}}{x{i}^{2}+y{i}^{2}}}x{i}^{2}}{\sum x{i}^{2}}}}$
${\displaystyle F={\frac {\sum 2x{i}y{i}}{\sum x{i}^{2}+y{i}^{2}}}}$
Note, sums may be replaced with integrals for continuous distributions depending on other continuous variables (i.e. ${\displaystyle \sum \rightarrow \int d\xi }$, ${\displaystyle x{i}\rightarrow x(\xi )}$, ${\displaystyle y{i}\rightarrow y(\xi )}$).
These definitions reduce to the classical binary versions when ${\displaystyle x{i},y{i}\in \{0,1\}}$. However, continuous metrics reveal a deeper mathematical elegance. Consider a completely wrong ML model with random signal. Traditional binary metrics, blind to magnitude and sign, can still award such a model positive precision, recall and/or F-score (even 25% or higher for dense signal). The continuous formulas, by contrast, return exactly 0 for precision, recall, and F-score in this situation – because when expected and observed signals do not correlate, the numerator terms cancel to zero.