<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>

CC BY-SA 4.0
2020-01-04T11:53:51.480Z
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.
Clement
CC BY-SA 4.0
2020-01-04T23:27:11.663Z
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?
nbro
CC BY-SA 4.0
2020-01-05T18:29:24.003Z
@nbro In my test set which has around 80k samples, it always predicts class A.
Johnny P.
CC BY-SA 4.0
2020-01-05T19:36:39.897Z
@JohnnyP. But do you have the labels for your 80k test samples?
nbro
CC BY-SA 4.0
2020-01-06T08:56:41.510Z
@nbro Yes, I have them.
Johnny P.
CC BY-SA 4.0
2020-01-10T09:44:59.967Z
@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
bit_scientist
<neural-networks><machine-learning><deep-learning>
Rarely predict minority class imbalanced datasets
Johnny P.
# 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**: @username_2 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**: @username_2 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

