Body: <p>I have a dataset in which class A has 99.8%, class B 0.1% and class C 0.1%. If I train my model on this dataset, it predicts always class A. If I do oversampling, it predicts the classes evenly. I want my model to predict class A around 98% of the time, class B 1% and class C 1%. How can I do that?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-04T11:53:51.480Z
Comments.Text: What do you mean? If you do oversampling, the results of inference will still be correct, with whatever percentage A is and whatever percentage B is and C.
Comments.UserDisplayName: Clement
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-04T23:27:11.663Z
Comments.Text: Hi and welcome to this community! You say "If I train my model on this dataset, it predicts always class A", but are you sure it always predicts A? Have you tried to give an input similar to the ones in class B or C and see if it predicts respectively B or C?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-05T18:29:24.003Z
Comments.Text: @nbro In my test set which has around 80k samples, it always predicts class A.
Comments.UserDisplayName: Johnny P.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-05T19:36:39.897Z
Comments.Text: @JohnnyP. But do you have the labels for your 80k test samples?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-06T08:56:41.510Z
Comments.Text: @nbro Yes, I have them.
Comments.UserDisplayName: Johnny P.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-10T09:44:59.967Z
Comments.Text: @JohnnyP. If possible try to balance your classes and train again. If class distributions are that extreme and similarity of classes are high, then you have no other choice but balance them first IMO
Comments.UserDisplayName: bit_scientist
Tags: <neural-networks><machine-learning><deep-learning>
Title: Rarely predict minority class imbalanced datasets
UserDisplayName: Johnny P.
ThreadText: # Rarely predict minority class imbalanced datasets
  
  (Asked by: username_0 on 2020-01-04)
  
  I have a dataset in which class A has 99.8%, class B 0.1% and class C 0.1%. If I train my model on this dataset, it predicts always class A. If I do oversampling, it predicts the classes evenly. I want my model to predict class A around 98% of the time, class B 1% and class C 1%. How can I do that?
  
  **Tags:** neural-networks, machine-learning, deep-learning
  > **Comments:**
  > **username_1**: What do you mean? If you do oversampling, the results of inference will still be correct, with whatever percentage A is and whatever percentage B is and C.  
  > **username_2**: Hi and welcome to this community! You say "If I train my model on this dataset, it predicts always class A", but are you sure it always predicts A? Have you tried to give an input similar to the ones in class B or C and see if it predicts respectively B or C?  
  > **username_0**: @nbro In my test set which has around 80k samples, it always predicts class A.  
  > **username_2**: @JohnnyP. But do you have the labels for your 80k test samples?  
  > **username_0**: @nbro Yes, I have them.  
  > **username_3**: @JohnnyP. If possible try to balance your classes and train again. If class distributions are that extreme and similarity of classes are high, then you have no other choice but balance them first IMO  
  
  ---
  
  ## 0 answers
  
  