Answers.Body: <p>In the case of binary classification, i.e. when you have two classes <span class="math-container">$A$</span> and <span class="math-container">$B$</span>, the recall is defined as</p>
  <p><span class="math-container">$${\displaystyle {\text{Recall}}={\frac {tp}{tp+fn}}}$$</span></p>
  <p>Similarly, the precision as</p>
  <p><span class="math-container">$${\displaystyle {\text{Precision}}={\frac {tp}{tp+fp}}}$$</span></p>
  <p>where, <strong>if you choose and fix a class <span class="math-container">$A$</span> as your main class (or class of interest)</strong>,</p>
  <ul>
  <li><p><span class="math-container">$tp$</span> is the number of true positives (i.e. the number of observations that have been classified as <span class="math-container">$A$</span> and actually belong to class <span class="math-container">$A$</span>, i.e. they have been correctly classified)</p>
  </li>
  <li><p><span class="math-container">$fn$</span> is the number of false negatives (i.e. the number of observations that have been <em>incorrectly</em> classified as <span class="math-container">$B$</span>, so, in this case of binary classification, they actually belong to class <span class="math-container">$A$</span>)</p>
  </li>
  <li><p><span class="math-container">$fp$</span> is the number of false positives (i.e. the number of observations that have been <em>incorrectly</em> classified as <span class="math-container">$A$</span>)</p>
  </li>
  </ul>
  <p>In this context, the confusion matrix will be a <span class="math-container">$2 \times 2$</span> matrix because you have two predictions (one for each of the two classes) compared against the two ground-truth labels (or classes).</p>
  <p>In the context of multi-class classification, where you have <span class="math-container">$N &gt; 2$</span> classes, you will have a <span class="math-container">$N \times N$</span> 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 <span class="math-container">$M$</span> represent your confusion matrix, so <span class="math-container">$M_{ij}$</span> is the entry of this confusion matrix at row <span class="math-container">$i$</span> and column <span class="math-container">$j$</span>. Then the recall, <strong>for class <span class="math-container">$i$</span></strong> (i.e. your main class, as <span class="math-container">$A$</span> above), is defined as</p>
  <p><span class="math-container">$$\text{Recall}_{~i} = \cfrac{M_{ii}}{\sum_j M_{ij}}$$</span></p>
  <p><span class="math-container">$$\text{Precision}_{~i} = \cfrac{M_{ii}}{\sum_j M_{ji}}$$</span></p>
  <p>In other words, the recall for a certain class <span class="math-container">$i$</span> is computed as the fraction of the diagonal element <span class="math-container">$M_{ii}$</span> and the sum of all elements in that row <span class="math-container">$i$</span>. Similarly, the precision is computed as the fraction of <span class="math-container">$M_{ii}$</span> and the sum of all elements in column <span class="math-container">$i$</span>.</p>
  <p>If the true positives (i.e. the diagonal elements <span class="math-container">$M_{ii}$</span>) of all classes are indeed bigger compared to the denominator, the recall can indeed be bigger than the precision for all classes.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-08T00:42:41.443Z
Answers.Text: Thanks mate, very good explanation, I explained my concern below, can you have a look on that? thank you!
Answers.UserDisplayName: Cheleeger Ken
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-07T23:32:34.270Z
Answers.LastActivityDate: 2020-07-07T23:32:34.270Z
Answers.UserDisplayName: nbro
Answers.Body: <p>This image have mathematical proof that how &quot;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.
  (<a href="https://i.sstatic.net/vgeHB.jpg" rel="nofollow noreferrer">https://i.sstatic.net/vgeHB.jpg</a>)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-04T08:21:45.203Z
Answers.Text: Can you please post text answers where possible? Some people might not be able to read text from an image.
Answers.UserDisplayName: Oliver Mason
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-04T14:48:51.527Z
Answers.Text: 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.
Answers.UserDisplayName: Prashant Goswami
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-03T16:20:07.503Z
Answers.LastActivityDate: 2021-08-03T16:20:07.503Z
Answers.UserDisplayName: Prashant Goswami
Body: <p>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.</p>
  <p>As following table shows (this is from some paper):</p>
  <p><a href="https://i.sstatic.net/Cf2qZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Cf2qZ.png" alt="enter image description here" /></a></p>
  <p><em>Is it possible that every class has a higher recall than precision for multi-class classification?</em></p>
  <p>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?</p>
  <p>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.</p>
  <p>I tried to make a fake confusion matrix to simulate the result, but I failed. Can someone explain it to me?</p>
  <h3>this is a further description:</h3>
  <p>Assume we have classified 10 data into 3 classes, and we have a confusion matrix like this,</p>
  <p><a href="https://i.sstatic.net/sQpQt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/sQpQt.png" alt="enter image description here" /></a><br />
  if we want to keep recall bigger than precision over each class (this case 0,1,2) respectively, we need to keep:<br />
  x1+x2 &lt; x3+x5<br />
  x3+x4 &lt; x1+x6<br />
  x5+x6 &lt; x2+x4</p>
  <p>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.</p>
  <p>Hence, I think to get recall higher than precision on all classes is not feasible, because the quantity of the total classification is fixed.</p>
  <p>I don't know am I right or wrong, please tell me if I made a mistake.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-07T22:58:58.320Z
Comments.Text: The precision and recall are typically computed for binary classification problems. [This article](https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html) 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.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-07T23:38:20.333Z
Comments.Text: Can you please provide the link to the paper where you took that diagram from?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-07T23:59:53.737Z
Comments.Text: Thanks mate, this is the link,https://link.springer.com/article/10.1007/s00766-007-0045-1,
Comments.UserDisplayName: Cheleeger Ken
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-08T14:20:58.497Z
Comments.Text: 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?
Comments.UserDisplayName: nbro
Tags: <machine-learning><text-classification><metric><precision>
Title: Is it possible that every class has a higher recall than precision for multi-class classification?
UserDisplayName: Cheleeger Ken
ThreadText: # Is it possible that every class has a higher recall than precision for multi-class classification?
  
  (Asked by: username_0 on 2020-07-07)
  
  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):
  
  [![enter image description here](https://i.sstatic.net/Cf2qZ.png)](https://i.sstatic.net/Cf2qZ.png)
  
  *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,
  
  [![enter image description here](https://i.sstatic.net/sQpQt.png)](https://i.sstatic.net/sQpQt.png)  
  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.
  
  **Tags:** machine-learning, text-classification, metric, precision
  
  > **Comments:**
  > **username_1**: The precision and recall are typically computed for binary classification problems. [This article](https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html) 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.  
  > **username_1**: Can you please provide the link to the paper where you took that diagram from?  
  > **username_0**: Thanks mate, this is the link,https://link.springer.com/article/10.1007/s00766-007-0045-1,  
  > **username_1**: 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?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-07-07. Score: 1
  
  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.
  
  > **Comments:**
  > **username_0**: Thanks mate, very good explanation, I explained my concern below, can you have a look on that? thank you!  
  
  ---
  
  ### Answer by username_2 on 2021-08-03. Score: 0
  
  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.sstatic.net/vgeHB.jpg>)
  
  > **Comments:**
  > **username_3**: Can you please post text answers where possible? Some people might not be able to read text from an image.  
  > **username_2**: 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.  
  
  ---
  
  