Precision and Recall

What is Precision and Recall?

Precision and recall are measurements for the accuracy of information retrieval, classification, and identification within a computer program. Precision, or the positive predictive value, refers to the fraction of relevant instances among the total retrieved instances. Recall, also known as sensitivity, refers to the fraction of relevant instances retrieved over the total amount of relevant instances. In short, precision and recall are measurements of relevance.

By Walber - Own work, CC BY-SA 4.0, Link

Precision = TP / (TP + FP) 
Recall = TP / (TP + FN)

In some cases, precision and recall are measured together in what is known as the F-score, or F-measure. The F-score is the harmonic average of the precision and recall measurements. A perfect F-score is represented with a value of 1, and worst score with 0. Similarly, it is possible to interpret precision and recall measurements as probabilities. In this case, precision is the probability that a randomly selected retrieved document is relevant, and recall is the probability that a randomly retrieved relevant document is retrieved.

An Example of Precision and Recall in Machine Learning

Imagine a machine learning algorithm is tasked with identifying the number of bananas within a bowl of fruit. In total, the bowl contains 10 pieces of fruit, 4 of which are bananas, and 6 are apples. The algorithm determines that there are 5 bananas, and 5 apples. The number of bananas that were counted correctly are known as true positives, while the items that were identified incorrectly as bananas are called false positives. In this example, there are 4 true positives, and one false positive, making the algorithms precision 4/5, and its recall is 4/10.