liveBook · Manning

Precision

As explained in Grokking Machine Learning, Second Edition

Precision is the proportion of inputs predicted as positive that are actually positive.

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

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Defines precision, gives its confusion-matrix formula, and works through spam examples before comparing it with recall.
Examples
Uses spam-filter confusion matrices, car recalls, earthquake sensors, recommendations, medical diagnosis, and voice assistants.
What it assumes
Assumes basic classification predictions and teaches true positives, false positives, and confusion-matrix interpretation alongside precision.
What you can do after
Evaluate classification predictions, calculate precision from a confusion matrix, and choose it when false positives are costly.
How it connects
Connects precision to false positives, confusion matrices, recall, F-score, sensitivity, specificity, and accuracy.

Also explained in

Compare how 27 books explain precision →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.