liveBook · Manning

Precision

As explained in Deep Learning with PyTorch, Second Edition

Numerical precision is the fineness with which a numerical representation or computation distinguishes and retains values.

A classifier can look accurate while doing a poor job of finding what matters. In a heavily negative nodule dataset, predicting “non-nodule” for everything produces a high percentage correct but misses every nodule. Classification precision asks a narrower question: when the model predicts a nodule, how often is it right? section 14.0 section 14.3.2

Precision is true positives divided by all positive predictions: true positives / (true positives + false positives). A true positive is a correctly predicted nodule; a false positive is a non-nodule incorrectly predicted as a nodule. High precision means few false alarms among the model’s positive predictions. section 14.3.2 section 14.3.3

A cautious classifier

Imagine a guard dog that barks only when nearly certain it has spotted a burglar. Almost every bark is useful, so its precision is high. But it may let many burglars pass unnoticed. Likewise, raising a classifier’s threshold can improve precision while hurting recall; precision alone cannot establish whether the classifier is useful. section 14.3.2 section 14.3.4

Calculate and inspect it during training

Count correct positive predictions as truePos_count, and negative samples incorrectly predicted positive as falsePos_count. Then compute precision = truePos_count / np.float32(truePos_count + falsePos_count) and log it each epoch alongside recall and F1 score. Check the denominator: when the model predicts nothing positive, both counts can be zero and precision becomes nan. A high overall accuracy can hide that failure. section 14.3.3 section 14.3.5

Recall measures a different failure: missed positives. The F1 score combines precision and recall because changing the classification threshold can make either one look good at the other’s expense. section 14.3.4

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Defines the true-positive ratio, implements it from classification counts, and examines undefined results when no positives are predicted.
Examples
Uses a cautious guard dog and a nodule classifier that reports high accuracy while missing positive samples.
What it assumes
Introduces true and false positive counts through nodule labels while assuming familiarity with a classifier’s predictions.
What you can do after
Diagnose/debug with it by logging precision alongside recall and checking for false positives or undefined values.
How it connects
Connects precision to false positives, classification thresholds, recall, and F1 score.

Also explained in

Compare how 9 books explain precision →

Related concepts

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