Body: <p>Consider a classification problem using machine learning techniques (e.g. malware detection). In such a problem, is it necessary that the number of samples from each class (in the mentioned example, the malware family) that are used to learn the model, be almost the same as the other classes?
  I asked this question because there may be many more examples for some classes than others and naturally the model will learn more accurately about these classes. But if it is necessary to have the same approximate number of samples in each classes, then it is necessary to ignore a large number of collected samples.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-18T13:34:12.620Z
Comments.Text: No. See [here on Cross Validated](https://stats.stackexchange.com/questions/357466/are-unbalanced-datasets-problematic-and-how-does-oversampling-purport-to-he).
Comments.UserDisplayName: Igor F.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-19T10:40:43.110Z
Comments.Text: As @IgorF. says, no. And in real-world, you seldom see balanced classes.
Comments.UserDisplayName: lpounng
Tags: <machine-learning><classification><datasets><imbalanced-datasets>
Title: Is it necessary that the number of samples of one class be balanced with other classes in a classification problem?
UserDisplayName: user16385455
ThreadText: # Is it necessary that the number of samples of one class be balanced with other classes in a classification problem?
  
  (Asked by: username_0 on 2024-03-18)
  
  Consider a classification problem using machine learning techniques (e.g. malware detection). In such a problem, is it necessary that the number of samples from each class (in the mentioned example, the malware family) that are used to learn the model, be almost the same as the other classes?
  I asked this question because there may be many more examples for some classes than others and naturally the model will learn more accurately about these classes. But if it is necessary to have the same approximate number of samples in each classes, then it is necessary to ignore a large number of collected samples.
  
  **Tags:** machine-learning, classification, datasets, imbalanced-datasets
  > **Comments:**
  > **username_1**: No. See [here on Cross Validated](https://stats.stackexchange.com/questions/357466/are-unbalanced-datasets-problematic-and-how-does-oversampling-purport-to-he).  
  > **username_2**: As @IgorF. says, no. And in real-world, you seldom see balanced classes.  
  
  ---
  
  ## 0 answers
  
  