The precision is defined as

$$\text{precision} = \frac{\text{true positive}}{\text{true positive} + \text{false positive}}$$

Is there any definition what this value should be if there is no positive classification (but of course positive elements)?

  • $\begingroup$ So the classifier would predict all negative elements when tested? Whatever the classifier model class, your estimate from a test set would show "this classifier is much the same as guessing negative in all cases". I doubt there is any default other than the arithmetic one where $\frac{0}{0}$ is not defined. $\endgroup$ – Neil Slater Jul 9 '16 at 19:27
  • $\begingroup$ @NeilSlater Yes, I am talking about a "classifier" which "predicts" always just the most common class (the negative one, in this case). $\endgroup$ – Martin Thoma Jul 9 '16 at 19:33

I just found that sklearn.metrics.precision_score handles it like this:

>>> sklearn.metrics.precision_score(y_true, y_pred)
  UndefinedMetricWarning: Precision is ill-defined and being
    set to 0.0 due to no predicted samples.
    'precision', 'predicted', average, warn_for)

So they give a warning and set it to 0.

| improve this answer | |

I have worked on several practical projects. In these projects we designed classifiers to deal with practical problems. Before I started working on practical I used to be very interested in : overall classification accuracy, sensitivity and specificity. In practical life, usually they care in two values: Positive predictive value " precision " and positive percentage PP "how many samples are predicted as positive". The pp value measures the usefulness of this practical solution while the ppv value measures the quality of your solution. Based on my understanding if the pp value is zero the ppv value is not defined and the solution itself is not valid

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.