I'm dealing with a multi-class classification problem with around 30 categories.
This problem has a severe class imbalance:
- Around 300 examples for the least common class.
- Around 100k examples for the most common class.
I don't want the classification model to be dummy and predict the most common class for most of the examples, for this reason, I'm using
class_weight='balanced' in my
LogisticRegression from sklearn. However, in this case, the classes that the algorithm predicts are mostly the less frequent ones. I understand the model overfits them somehow, as it assigns every sample from these class a very high weight.
On the other hand, if I don't apply the class weights, the model predicts the most common categories.
Is there a way to solve this? Is there a way to ensure the model predicts approximately the same proportion of samples for each category?