Precision answers a practical question: when a classifier predicts positive, how often is it correct? It is especially useful when false positives are costly. section 7.8
Calculate precision as true positives divided by all predicted positives: precision = TP / (TP + FP). The denominator includes both correct positive predictions and false alarms. section 7.8 section 7.17
Spam filtering
Suppose a spam filter deletes 35 spam emails and 10 legitimate emails. Its precision is 35 / (35 + 10) = 77.7%. A second filter deleting 30 spam emails and 5 legitimate emails reaches 85.7%, despite both models having 85% accuracy. The higher-precision filter makes fewer false-positive deletions among its positive predictions. section 7.8
Balance precision against recall according to the cost of errors. A spam model should emphasize precision because legitimate messages should not be treated as spam; a medical model may emphasize recall when missed positives are more dangerous. section 7.11 section 7.18
Figure 7.9 The top row of the confusion matrix gives us recall and sensitivity: the ratio between the number of true positives and the sum of true positives and false negatives. The leftmost column gives us precision: the ratio between the number of true positives and the sum of true positives and false positives. The bottom row gives us specificity: the ratio between the number of false positives and the sum of false positives and true negatives.
Use the confusion matrix to locate precision in the leftmost predicted-positive column: true positives divided by true positives plus false positives. section 7.17
Practice applying precision by:
- Calculating precision for a recommendation model from its predictions. section 7.19
- Choosing precision or recall when false-positive and false-negative costs differ across cars, voice assistants, medical diagnosis, and spam detection. section 7.19


























