Answers.Body: <p>I would make the distribution of the classes in test and validation sets the same as in the training set (and as in the whole original set). Anyway all your metrics are relative, not absolute and designed to provide reasonable results when classes are not ideally balanced.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-16T09:08:33.080Z
Answers.LastActivityDate: 2020-06-16T09:08:33.080Z
Answers.UserDisplayName: oleg.mosalov
Body: <p>I have 5 classes of pictures to classify:</p>
  
  <p>0 -> ~<strong>3 200</strong> (~800 initial number before interference and duplication)</p>
  
  <p>1 -> ~<strong>9 000</strong> (I reduced from ~90 000)</p>
  
  <p>2 -> ~<strong>8 000</strong></p>
  
  <p>3 -> ~<strong>3 000</strong></p>
  
  <p>4 -> ~<strong>7 200</strong></p>
  
  <p>How to divide the data? </p>
  
  <p>Now I have divided the data giving <strong>2 000</strong> to test and <strong>2 000</strong> to validation set 
  by taking a fixed number of images (<strong>400</strong>) from each class. I don't have much knowledge so I don't know if this is a good division of data. 
  The attached picture shows the results on the test data after about 60 epoch of CNN with 15 layers. </p>
  
  <p><a href="https://i.sstatic.net/kxCgs.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kxCgs.png" alt="enter image description here"></a></p>
  
  <p>The network continues to overfiting, and the results of validation and test set do not improve. 
  I know that I could definitely improve my model but I would like to divide the data in some thoughtful and reasonable way. Pictures are spectrograms and are in RGB format.</p>
  
Tags: <deep-learning><classification><training><datasets>
Title: How to split data into training validation and test set when the number of data in classes varies greatly?
UserDisplayName: Dominiksr
ThreadText: # How to split data into training validation and test set when the number of data in classes varies greatly?
  
  (Asked by: username_0 on 2020-06-16)
  
  I have 5 classes of pictures to classify:
  
  0 -> ~**3 200** (~800 initial number before interference and duplication)
  
  1 -> ~**9 000** (I reduced from ~90 000)
  
  2 -> ~**8 000**
  
  3 -> ~**3 000**
  
  4 -> ~**7 200**
  
  How to divide the data?
  
  Now I have divided the data giving **2 000** to test and **2 000** to validation set
  by taking a fixed number of images (**400**) from each class. I don't have much knowledge so I don't know if this is a good division of data.
  The attached picture shows the results on the test data after about 60 epoch of CNN with 15 layers.
  
  [![enter image description here](https://i.sstatic.net/kxCgs.png)](https://i.sstatic.net/kxCgs.png)
  
  The network continues to overfiting, and the results of validation and test set do not improve.
  I know that I could definitely improve my model but I would like to divide the data in some thoughtful and reasonable way. Pictures are spectrograms and are in RGB format.
  
  **Tags:** deep-learning, classification, training, datasets
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-16. Score: 1 | Accepted answer
  
  I would make the distribution of the classes in test and validation sets the same as in the training set (and as in the whole original set). Anyway all your metrics are relative, not absolute and designed to provide reasonable results when classes are not ideally balanced.
  
  
  ---
  
  