# What are correct values for precision and recall in edge cases?

Precision is defined as:

p = true positives / (true positives + false positives)


Is it correct that, as true positives and false positives approach 0, the precision approaches 1?

Same question for recall:

r = true positives / (true positives + false negatives)


I am currently implementing a statistical test where I need to calculate these values, and sometimes it happens that the denominator is 0, and I am wondering which value to return for this case.

P.S.: Excuse the inappropriate tag, I wanted to use recall, precision and limit, but I cannot create new Tags yet.

• I don't think we need limit tag. – user88 Aug 17 '10 at 11:08
• Presumably you're attempting to quantify performance of some diagnostic procedure; is there any reason you're not using a proper signal detection theory metric like d', A', or area under the ROC curve? – Mike Lawrence Aug 17 '10 at 11:19
• @Mike, precision and recall are common evaluation metrics in, e.g., information retrieval where ROC, or in particular specificity is awkward to use because you already expect a high number of false positives. – user979 Aug 17 '10 at 18:02

Given a confusion matrix:

            predicted
(+)   (-)
---------
(+) | TP | FN |
actual      ---------
(-) | FP | TN |
---------


we know that:

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


Lets consider the cases where the denominator is zero:

• TP+FN=0 : means that there were no positive cases in the input data
• TP+FP=0 : means that all instances were predicted as negative
• Extending your answer: If TP=0 (as in both cases), recall is 1, since the method has discovered all of none true positives; precision is 0 if there is any FP and 1 otherwise. – user88 Aug 17 '10 at 11:44

Answer is Yes. The undefined edge cases occur when true positives (TP) are 0 since this is in the denominator of both P & R. In this case,

• Recall = 1 when FN=0, since 100% of the TP were discovered
• Precision = 1 when FP=0, since no there were no spurious results

This is a reformulation of @mbq's comment.

I am familiar with different terminology. What you call precision I would positive predictive value (PPV). And what you call recall I would call sensitivity (Sens). :