# Is it possible that every class has a higher recall than precision for multi-class classification?

I am a student learning machine learning recently, and one thing is keep confusing me, I tried multiple sources and failed to find the related answer.

As following table shows (this is from some paper):

Is it possible that every class has a higher recall than precision for multi-class classification?

Recall can be higher than precision over some class or overall performance which is common, but is it possible to keep recall greater than precision for every class?

The total amount of test data is fixed, so, to my understanding, if the recall is greater than the precision for one class, it is a must that the recall must be smaller than the precision for some other classes.

I tried to make a fake confusion matrix to simulate the result, but I failed. Can someone explain it to me?

### this is a further description:

Assume we have classified 10 data into 3 classes, and we have a confusion matrix like this,

if we want to keep recall bigger than precision over each class (this case 0,1,2) respectively, we need to keep:
x1+x2 < x3+x5
x3+x4 < x1+x6
x5+x6 < x2+x4

There is a conflict, because the sum of the left side equals to the sum of the right side in these inequalities, and the sum(x1...x6) = 10 - sum(a,b,c) in this case.

Hence, I think to get recall higher than precision on all classes is not feasible, because the quantity of the total classification is fixed.

I don't know am I right or wrong, please tell me if I made a mistake.

• The precision and recall are typically computed for binary classification problems. This article provides an example of how to compute the precision and recall for multi-class and multi-label classification problems too. But why do you think that if the recall is greater than the precision for one class, then the recall must be smaller than the precision for other classes? I am not saying you're wrong or right, I am just trying to understand why you think that's the case.
– nbro
Jul 7, 2020 at 22:58
• Can you please provide the link to the paper where you took that diagram from?
– nbro
Jul 7, 2020 at 23:38
• Thanks mate, this is the link,link.springer.com/article/10.1007/s00766-007-0045-1, Jul 7, 2020 at 23:59
• Your example indeed seems to show that there's something wrong with the table of the paper. Do they say in the paper how they compute the recall and precision?
– nbro
Jul 8, 2020 at 14:20

In the case of binary classification, i.e. when you have two classes $$A$$ and $$B$$, the recall is defined as

$${\displaystyle {\text{Recall}}={\frac {tp}{tp+fn}}}$$

Similarly, the precision as

$${\displaystyle {\text{Precision}}={\frac {tp}{tp+fp}}}$$

where, if you choose and fix a class $$A$$ as your main class (or class of interest),

• $$tp$$ is the number of true positives (i.e. the number of observations that have been classified as $$A$$ and actually belong to class $$A$$, i.e. they have been correctly classified)

• $$fn$$ is the number of false negatives (i.e. the number of observations that have been incorrectly classified as $$B$$, so, in this case of binary classification, they actually belong to class $$A$$)

• $$fp$$ is the number of false positives (i.e. the number of observations that have been incorrectly classified as $$A$$)

In this context, the confusion matrix will be a $$2 \times 2$$ matrix because you have two predictions (one for each of the two classes) compared against the two ground-truth labels (or classes).

In the context of multi-class classification, where you have $$N > 2$$ classes, you will have a $$N \times N$$ confusion matrix, for the same reason. In this case, the recall and precision are just an extension of the binary classification problem. More precisely, let $$M$$ represent your confusion matrix, so $$M_{ij}$$ is the entry of this confusion matrix at row $$i$$ and column $$j$$. Then the recall, for class $$i$$ (i.e. your main class, as $$A$$ above), is defined as

$$\text{Recall}_{~i} = \cfrac{M_{ii}}{\sum_j M_{ij}}$$

$$\text{Precision}_{~i} = \cfrac{M_{ii}}{\sum_j M_{ji}}$$

In other words, the recall for a certain class $$i$$ is computed as the fraction of the diagonal element $$M_{ii}$$ and the sum of all elements in that row $$i$$. Similarly, the precision is computed as the fraction of $$M_{ii}$$ and the sum of all elements in column $$i$$.

If the true positives (i.e. the diagonal elements $$M_{ii}$$) of all classes are indeed bigger compared to the denominator, the recall can indeed be bigger than the precision for all classes.

• Thanks mate, very good explanation, I explained my concern below, can you have a look on that? thank you! Jul 8, 2020 at 0:42

This image have mathematical proof that how "RECALL cannot be greater than PRECISION for all the classes in multi class classification and vice versa. Let me know if you have got any confusion regarding to it. (https://i.stack.imgur.com/vgeHB.jpg)

• Can you please post text answers where possible? Some people might not be able to read text from an image. Aug 4, 2021 at 8:21
• Sure, I will do that where it will be suitable, but if you have any confusion regarding to it, please let me know because it doesn't have something intense and thanks for the suggestion. Aug 4, 2021 at 14:48