Answers.Body: <p>Maybe not a satisfactory answer but I hope this will give you at least a slightly new perspective on how to think about binary vs multiclass problems in a machine learning way.</p>
  <p><strong>Let's start from the math:</strong> Binary classification and multiclass classification are basically the same, i.e. every loss formulated for binary classification is a special case of the same loss generalized to n classes. If you see explicit classes for both in every main machine learning frameworks is just due to specific different implementations for boosting a bit performances. But if we look at the formula of the main loss used for classification, i.e. cross entropy, you'll see that there is no difference at all between 2 and n classes</p>
  <ul>
  <li>Cros entropy: <span class="math-container">$$-\sum_{c=1}^{M}y_{o,c}log(p_{o,c})$$</span></li>
  <li>Binary cross entropy (the sum between the 2 classes is just expanded): <span class="math-container">$$−(ylog(p)+(1−y)log(1−p))$$</span></li>
  </ul>
  <p><strong>Moving on to your rationale:</strong> Not lung tumor is an heterogeneous class, hence splitting it into specific classes might help the model learning better features for each one of them. I don't agree a lot with this rationale for a simple reason: first, if it's possible to lean good features for subclasses of a macro category then mapping all those classes back to the main class should be trivial to learn for any deep learning architecture. The opposite instead does not hold. This is why despite the same math behind, tasks with less classes are usually easier to tackle. The only AI area I can think about that leverage this kind of rationale is multi task learning, in which similar tasks like classification and object segmentation/detection are combined to leverage more ground truth data. But in this case the advantage is the combination of different losses that help learning hierarchical features.</p>
  <p><strong>So what to do</strong>: I personally feel that the right angle to look at the problem is investigating the amount of data at your disposal and their labels distribution. If your fine grained labels generate a sort of balanced distribution then I would go for multiclass, if not I would go for binary classification, even if the binary labels distribution is highly skewed, since for this scenario Focal loss (a weighted variation of cross entropy) works just fine.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-26T14:54:50.157Z
Answers.Text: thank you for taking the time to provide a response.  The fact that the binary and multiclass cross entropy loss functions take on similar forms is well-appreciated.  However, just because the functions are of similar form does not necessarily mean that they are going to be equal/similar.
Answers.UserDisplayName: Snehal Patel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-26T14:57:53.267Z
Answers.Text: Second, the problem of mapping fine labels (`trachea`, `lung`, `blood vessels`) to coarse labels (`not lung tumor`) is--I agree with you--easy.  But this isn't a mapping problem.  This is a learning problem.  Coarse labels in a hierarchy may be easier to learn when the fine labels share common features.  This is levered by various hierarchical approaches.  However, this approach breaks down when the fine labels do not share common features, as we have here.
Answers.UserDisplayName: Snehal Patel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-28T08:36:18.307Z
Answers.Text: about the second point I was indeed talking about learning in the answer. I don't agree with your last statement, hierarchical learning is not about shared features, actually learning differentiated features (good clustered embedding vectors) is the main goal in multi task learning for high level tasks. If I want to better detect faces I need to be able to detect different face elements first, like eyes or ears, which have nothing to do with each other. Once the model learn that, that the different feature layers will just learn to fire to the same output nodes related to the face class.
Answers.UserDisplayName: Edoardo Guerriero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-28T08:42:42.897Z
Answers.Text: point is that you can also learn directly detect faces without clustered features, i.e. with features layers that detect a bit of everything instead of being specialized. So again, unless your dataset is perfectly balanced I don't see why you should make your life harder going down the multiclass rode.
Answers.UserDisplayName: Edoardo Guerriero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-22T08:38:49.623Z
Answers.LastActivityDate: 2022-11-22T08:38:49.623Z
Answers.UserDisplayName: Edoardo Guerriero
Answers.Body: <p>********<strong>Two-Class Approach (Lung Tumor vs. Not Lung Tumor):</strong></p>
  <p>Simpler to Implement: Here, the model just needs to decide if a part of the image is a lung tumor or not. This approach is straightforward and focuses directly on what you care about.</p>
  <p>Mixed Background Issue: The problem is that the &quot;Not Lung Tumor&quot; category includes a lot of different things, like lungs, heart, blood vessels, etc. This makes it harder for the model because it's dealing with a big, mixed bag of other stuff.
  Multiclass Approach (Lung Tumor, Lung, Trachea, etc.):</p>
  <p>More Specific Learning: By teaching the model to recognize different parts of the image (like the lung, heart, trachea), you're giving it more specific categories to work with. This could help the model better understand what a lung tumor is by knowing what everything else is too.</p>
  <p>More Work: However, this method requires more effort because you need to label (or annotate) all these different parts in your training data, which can be time-consuming and expensive.</p>
  <p>Which is Better for Lung Tumor Segmentation?</p>
  <p>Depends on the Situation: If you have the time and resources to label all the different parts (like the lungs, heart, etc.), the multiclass approach could help the model learn better and potentially improve accuracy in finding lung tumors.
  Quick and Focused: If you're short on time or resources, the two-class approach is simpler and might still work well, though it might struggle a bit with the mixed &quot;Not Lung Tumor&quot; category.</p>
  <p>In summary, adding more classes can help the model learn better, but it's more work. If your main goal is just to find lung tumors and you're okay with some extra effort, the multiclass approach could be worth it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-16T18:18:32.763Z
Answers.Text: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answers.UserDisplayName: Community
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-13T12:31:17.323Z
Answers.LastActivityDate: 2024-08-13T12:31:17.323Z
Answers.UserDisplayName: mak_97
Body: <p><strong>BACKGROUND:</strong>  I have a real world problem of developing a U-net-like model for segmenting lung tumors in lung CT images.</p>
  <p>On the one hand, I can make this a <strong>two class problem</strong>:</p>
  <pre><code> 1. lung tumor
   2. not lung tumor
  </code></pre>
  <p>On the other hand, I can make this a <strong>multiclass problem</strong> (for example):</p>
  <pre><code> 1. lung tumor
   2. lung
   3. trachea
   4. heart
   5. blood vessels
   6. etc.
  </code></pre>
  <p>Ultimately, I'm only interested in getting the lung tumor right.  Thus, the &quot;class of interest&quot; (mentioned in the title) is <code>lung tumor</code>.  All other classes are not necessary for my analysis, BUT my intuition is telling me that including more classes may improve the model's ability to segment lung tumors.  My <em>rationale</em> is that <code>not lung tumor</code> is very heterogeneous category that can be difficult for a model to classify a pixel into, but giving the model a set of more specific categories for commonly occurring structures may be helpful to model learning.  I am aware that the multiclass approach results in more manual annotations (i.e., time, fatigue, and costs), but that is not the focus of this question.</p>
  <p><strong>SPECIFIC QUESTION:</strong>  Which approach -- the two class or multiclass -- will yield higher accuracy for <code>lung tumor</code> segmentation on CT images?</p>
  <p><strong>REQUIREMENTS:</strong>  I seek a response that sheds deep insight into this problem.  Responses founded on established mathematical principles are acceptable.  Responses founded on empirical evidence from credible literature references are acceptable.  The evidence need not be specific to lung tumors, but it should be directly relevant to segmentation tasks.</p>
  <p><strong>PRIOR RESEARCH:</strong>  I have scoured the literature for a head-to-head comparison of these two approaches, but have not found anything useful for lung tumor segmentation.</p>
  <p><strong>RELEVANCE TO THE AI COMMUNITY:</strong>  While my problem is related to lung tumor segmentation, I believe the problem type is of general interest to the broader AI community.  For example, one may be interested in segmenting peoples' eyes in facial images, and one can ask whether they should have two classes (<code>eyes</code> vs. <code>not eyes</code>) or multiple classes (<code>eyes</code> vs. <code>nose</code> vs <code>lips</code> vs. <code>chin</code> vs....).  <em>Prior knowledge about which method is better would help people plan their annotation approach before embarking on a long and expensive annotation journey.</em></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-25T01:37:05.433Z
Comments.Text: Does anyone have suggestions on how to improve this post in order to get answers?
Comments.UserDisplayName: Snehal Patel
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-23T05:53:41.890Z
Comments.Text: On a pure theoretical basis there's no difference between a 2-class problem or a multi-class problem via more perceptrons in the first layer to correctly partition the multi-feature space as a preparation to fully match target outputs. But if some patterns from the problematic *heterogeneous* lung-tumor class are mostly different and identifiable from your other multi-classes patterns, then intuitively your NN's probability to misclassify one lung-tumor sample would be smaller (more accurate).
Comments.UserDisplayName: cinch
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-24T12:43:39.637Z
Comments.Text: @mohottnad, I am unclear why the first layer needs more perceptrons.  Isn't the first layer the input layer, and so shouldn't the number of perceptrons not change whether it is binary or multi-class?
Comments.UserDisplayName: Snehal Patel
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-24T12:49:29.573Z
Comments.Text: Also, I did not say that the `lung tumor` class is heterogeneous.  Rather, I said that the `not lung tumor` class would be heterogeneous because it would include everything else (e.g. normal lung, trachea, heart, blood vessels, etc.).  Thus the class would be difficult to learn.  In a multiclass setting, that "heterogenous" class would be broken down.  My guess is that giving these smaller more "homogeneous" classes would be easier to "learn".
Comments.UserDisplayName: Snehal Patel
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-24T19:02:01.540Z
Comments.Text: I meant first hidden layer in a MLP above to have more perceptrons to try to correctly partition the features space for multi-class. You can search “linear machines” for multiclassifier. Of course you can also try CNNs. If you interested lung tumor class is reliable to differentiate from non lung tumor classes, then intuitively why bother with multiclassifier?
Comments.UserDisplayName: cinch
Tags: <image-segmentation>
Title: How does accuracy (for a single class of interest) of a segmentation network vary with increasing number of classes?
UserDisplayName: Snehal Patel
ThreadText: # How does accuracy (for a single class of interest) of a segmentation network vary with increasing number of classes?
  
  (Asked by: username_0 on 2022-10-24)
  
  **BACKGROUND:** I have a real world problem of developing a U-net-like model for segmenting lung tumors in lung CT images.
  
  On the one hand, I can make this a **two class problem**:
  
  ```
   1. lung tumor
   2. not lung tumor
  
  ```
  
  On the other hand, I can make this a **multiclass problem** (for example):
  
  ```
   1. lung tumor
   2. lung
   3. trachea
   4. heart
   5. blood vessels
   6. etc.
  
  ```
  
  Ultimately, I'm only interested in getting the lung tumor right. Thus, the "class of interest" (mentioned in the title) is `lung tumor`. All other classes are not necessary for my analysis, BUT my intuition is telling me that including more classes may improve the model's ability to segment lung tumors. My *rationale* is that `not lung tumor` is very heterogeneous category that can be difficult for a model to classify a pixel into, but giving the model a set of more specific categories for commonly occurring structures may be helpful to model learning. I am aware that the multiclass approach results in more manual annotations (i.e., time, fatigue, and costs), but that is not the focus of this question.
  
  **SPECIFIC QUESTION:** Which approach -- the two class or multiclass -- will yield higher accuracy for `lung tumor` segmentation on CT images?
  
  **REQUIREMENTS:** I seek a response that sheds deep insight into this problem. Responses founded on established mathematical principles are acceptable. Responses founded on empirical evidence from credible literature references are acceptable. The evidence need not be specific to lung tumors, but it should be directly relevant to segmentation tasks.
  
  **PRIOR RESEARCH:** I have scoured the literature for a head-to-head comparison of these two approaches, but have not found anything useful for lung tumor segmentation.
  
  **RELEVANCE TO THE AI COMMUNITY:** While my problem is related to lung tumor segmentation, I believe the problem type is of general interest to the broader AI community. For example, one may be interested in segmenting peoples' eyes in facial images, and one can ask whether they should have two classes (`eyes` vs. `not eyes`) or multiple classes (`eyes` vs. `nose` vs `lips` vs. `chin` vs....). *Prior knowledge about which method is better would help people plan their annotation approach before embarking on a long and expensive annotation journey.*
  
  **Tags:** image-segmentation
  
  > **Comments:**
  > **username_0**: Does anyone have suggestions on how to improve this post in order to get answers?  
  > **username_1**: On a pure theoretical basis there's no difference between a 2-class problem or a multi-class problem via more perceptrons in the first layer to correctly partition the multi-feature space as a preparation to fully match target outputs. But if some patterns from the problematic *heterogeneous* lung-tumor class are mostly different and identifiable from your other multi-classes patterns, then intuitively your NN's probability to misclassify one lung-tumor sample would be smaller (more accurate).  
  > **username_0**: @mohottnad, I am unclear why the first layer needs more perceptrons.  Isn't the first layer the input layer, and so shouldn't the number of perceptrons not change whether it is binary or multi-class?  
  > **username_0**: Also, I did not say that the `lung tumor` class is heterogeneous.  Rather, I said that the `not lung tumor` class would be heterogeneous because it would include everything else (e.g. normal lung, trachea, heart, blood vessels, etc.).  Thus the class would be difficult to learn.  In a multiclass setting, that "heterogenous" class would be broken down.  My guess is that giving these smaller more "homogeneous" classes would be easier to "learn".  
  > **username_1**: I meant first hidden layer in a MLP above to have more perceptrons to try to correctly partition the features space for multi-class. You can search “linear machines” for multiclassifier. Of course you can also try CNNs. If you interested lung tumor class is reliable to differentiate from non lung tumor classes, then intuitively why bother with multiclassifier?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2022-11-22. Score: 0
  
  Maybe not a satisfactory answer but I hope this will give you at least a slightly new perspective on how to think about binary vs multiclass problems in a machine learning way.
  
  **Let's start from the math:** Binary classification and multiclass classification are basically the same, i.e. every loss formulated for binary classification is a special case of the same loss generalized to n classes. If you see explicit classes for both in every main machine learning frameworks is just due to specific different implementations for boosting a bit performances. But if we look at the formula of the main loss used for classification, i.e. cross entropy, you'll see that there is no difference at all between 2 and n classes
  
  * Cros entropy: $$-\sum\_{c=1}^{M}y\_{o,c}log(p\_{o,c})$$
  * Binary cross entropy (the sum between the 2 classes is just expanded): $$−(ylog(p)+(1−y)log(1−p))$$
  
  **Moving on to your rationale:** Not lung tumor is an heterogeneous class, hence splitting it into specific classes might help the model learning better features for each one of them. I don't agree a lot with this rationale for a simple reason: first, if it's possible to lean good features for subclasses of a macro category then mapping all those classes back to the main class should be trivial to learn for any deep learning architecture. The opposite instead does not hold. This is why despite the same math behind, tasks with less classes are usually easier to tackle. The only AI area I can think about that leverage this kind of rationale is multi task learning, in which similar tasks like classification and object segmentation/detection are combined to leverage more ground truth data. But in this case the advantage is the combination of different losses that help learning hierarchical features.
  
  **So what to do**: I personally feel that the right angle to look at the problem is investigating the amount of data at your disposal and their labels distribution. If your fine grained labels generate a sort of balanced distribution then I would go for multiclass, if not I would go for binary classification, even if the binary labels distribution is highly skewed, since for this scenario Focal loss (a weighted variation of cross entropy) works just fine.
  
  > **Comments:**
  > **username_0**: thank you for taking the time to provide a response.  The fact that the binary and multiclass cross entropy loss functions take on similar forms is well-appreciated.  However, just because the functions are of similar form does not necessarily mean that they are going to be equal/similar.  
  > **username_0**: Second, the problem of mapping fine labels (`trachea`, `lung`, `blood vessels`) to coarse labels (`not lung tumor`) is--I agree with you--easy.  But this isn't a mapping problem.  This is a learning problem.  Coarse labels in a hierarchy may be easier to learn when the fine labels share common features.  This is levered by various hierarchical approaches.  However, this approach breaks down when the fine labels do not share common features, as we have here.  
  > **username_2**: about the second point I was indeed talking about learning in the answer. I don't agree with your last statement, hierarchical learning is not about shared features, actually learning differentiated features (good clustered embedding vectors) is the main goal in multi task learning for high level tasks. If I want to better detect faces I need to be able to detect different face elements first, like eyes or ears, which have nothing to do with each other. Once the model learn that, that the different feature layers will just learn to fire to the same output nodes related to the face class.  
  > **username_2**: point is that you can also learn directly detect faces without clustered features, i.e. with features layers that detect a bit of everything instead of being specialized. So again, unless your dataset is perfectly balanced I don't see why you should make your life harder going down the multiclass rode.  
  
  ---
  
  ### Answer by username_3 on 2024-08-13. Score: 0
  
  \*\*\*\*\*\*\*\***Two-Class Approach (Lung Tumor vs. Not Lung Tumor):**
  
  Simpler to Implement: Here, the model just needs to decide if a part of the image is a lung tumor or not. This approach is straightforward and focuses directly on what you care about.
  
  Mixed Background Issue: The problem is that the "Not Lung Tumor" category includes a lot of different things, like lungs, heart, blood vessels, etc. This makes it harder for the model because it's dealing with a big, mixed bag of other stuff.
  Multiclass Approach (Lung Tumor, Lung, Trachea, etc.):
  
  More Specific Learning: By teaching the model to recognize different parts of the image (like the lung, heart, trachea), you're giving it more specific categories to work with. This could help the model better understand what a lung tumor is by knowing what everything else is too.
  
  More Work: However, this method requires more effort because you need to label (or annotate) all these different parts in your training data, which can be time-consuming and expensive.
  
  Which is Better for Lung Tumor Segmentation?
  
  Depends on the Situation: If you have the time and resources to label all the different parts (like the lungs, heart, etc.), the multiclass approach could help the model learn better and potentially improve accuracy in finding lung tumors.
  Quick and Focused: If you're short on time or resources, the two-class approach is simpler and might still work well, though it might struggle a bit with the mixed "Not Lung Tumor" category.
  
  In summary, adding more classes can help the model learn better, but it's more work. If your main goal is just to find lung tumors and you're okay with some extra effort, the multiclass approach could be worth it.
  
  > **Comments:**
  > **username_4**: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).  
  
  ---
  
  