Body: <p>I am training a neural network with a dataset that has 51 classes and 6766 data in it. I used 80% for the training set, 10% for validation, and 10% for the test. After training I got confusion matrix and I find out the last class is missed in the test set. So, I used data augmentation and used 27064 data and 80-10-10 splits again, but the last class name is missed again. I changed the size of the test split but the problem was not solved, and in every trial that I made, only the last class name is missed. How can I solve this?</p>
  <hr />
  <p><strong>EDIT:</strong> my dataset is images and in the original dataset, I have 104 data from the last class, after augmentation the entire dataset the last class has 416 data.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-27T01:08:02.973Z
Comments.Text: By "the last class name is missed", do you mean that you do not have any observation that has been labelled with the last class in the test dataset? If this, it's difficult to solve this problem without looking at the code. I'm not saying for you to include the code, because programming questions are off-topic, but have you tried to manually include such an observation in the test data? How many observations labelled with that last class do you have in the initial dataset?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-27T16:23:03.053Z
Comments.Text: Please show a histogram of the class distributions.  Also what type of data is this?  Are they images, categorical, text, etc.?  Did you augment the troublesome class data to 27,064 samples or did you augment the entire data set?  If the latter, how much did the 51st class grow?  You should only augment the 51st class.  How did you augment?  Are you sure you don't have some logic problem?  It is odd that you have 51 and not 50 classes and the problematic class is the last and 51.
Comments.UserDisplayName: Brian O'Donnell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-29T08:27:36.643Z
Comments.Text: @nbro I try manually inserting of last class data, and everything was ok, but in my train_test_split function, it doesn't include the last class. I edited the question and added some information  from the dataset and the number of the last class, please check it
Comments.UserDisplayName: SahaTib
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-29T08:28:15.663Z
Comments.Text: @BrianO'Donnell I edited the question and added some information from the dataset and augmentation, please check it.
Comments.UserDisplayName: SahaTib
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-29T23:41:44.783Z
Comments.Text: How are you splitting the data?  Are you preserving the class distributions?  Depending on how your data is arranged and how you are splitting it, you could be losing all the data in the last class for testing.  A good way to split data is with Scikit-Learn's stratified shuffle split.
Comments.UserDisplayName: Brian O'Donnell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-30T10:20:03.837Z
Comments.Text: @BrianO'Donnell I used this code x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.1, random_state=42)
Comments.UserDisplayName: SahaTib
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-06T12:30:35.843Z
Comments.Text: train_test_split is a random splitter and therefore does not preserve class distributions.  Try Scikit-Learn's stratified shuffle split.
Comments.UserDisplayName: Brian O'Donnell
Tags: <neural-networks><classification><training>
Title: The last target name is missed in the test set
UserDisplayName: SahaTib
ThreadText: # The last target name is missed in the test set
  
  (Asked by: username_0 on 2020-12-26)
  
  I am training a neural network with a dataset that has 51 classes and 6766 data in it. I used 80% for the training set, 10% for validation, and 10% for the test. After training I got confusion matrix and I find out the last class is missed in the test set. So, I used data augmentation and used 27064 data and 80-10-10 splits again, but the last class name is missed again. I changed the size of the test split but the problem was not solved, and in every trial that I made, only the last class name is missed. How can I solve this?
  
  ---
  
  **EDIT:** my dataset is images and in the original dataset, I have 104 data from the last class, after augmentation the entire dataset the last class has 416 data.
  
  **Tags:** neural-networks, classification, training
  > **Comments:**
  > **username_1**: By "the last class name is missed", do you mean that you do not have any observation that has been labelled with the last class in the test dataset? If this, it's difficult to solve this problem without looking at the code. I'm not saying for you to include the code, because programming questions are off-topic, but have you tried to manually include such an observation in the test data? How many observations labelled with that last class do you have in the initial dataset?  
  > **username_2**: Please show a histogram of the class distributions.  Also what type of data is this?  Are they images, categorical, text, etc.?  Did you augment the troublesome class data to 27,064 samples or did you augment the entire data set?  If the latter, how much did the 51st class grow?  You should only augment the 51st class.  How did you augment?  Are you sure you don't have some logic problem?  It is odd that you have 51 and not 50 classes and the problematic class is the last and 51.  
  > **username_0**: @nbro I try manually inserting of last class data, and everything was ok, but in my train_test_split function, it doesn't include the last class. I edited the question and added some information  from the dataset and the number of the last class, please check it  
  > **username_0**: @BrianO'Donnell I edited the question and added some information from the dataset and augmentation, please check it.  
  > **username_2**: How are you splitting the data?  Are you preserving the class distributions?  Depending on how your data is arranged and how you are splitting it, you could be losing all the data in the last class for testing.  A good way to split data is with Scikit-Learn's stratified shuffle split.  
  > **username_0**: @BrianO'Donnell I used this code x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.1, random_state=42)  
  > **username_2**: train_test_split is a random splitter and therefore does not preserve class distributions.  Try Scikit-Learn's stratified shuffle split.  
  
  ---
  
  ## 0 answers
  
  