3

I am trying to debug an issue with my classifier. The issue is that it always predicts the same class for a given input despite having close to an 80% accuracy.

I trained my CNN to detect the difference between 2 classes. class A has 2575 jpegs and class B has 665 jpegs.

Could this have caused my issue with my CNN always predicting the same class? Is this too much of an imbalance between the # of items in each class? In general, will my performance improve if I make the size of both classes the same(at 665 jpegs?)?

Sreehari R
  • 919
  • 4
  • 11
  • 21

1 Answers1

9

The problem seems to be a case of class imbalance and there are different ways to handle it:

  1. Weighted loss: You can penalise the reward for the majority loss function by computing a weighted cross entropy.
  2. Resampling the data: As you mentioned you can also downsample the majority class, to balance the classes. You can also upsample the minority class to make it even.
  3. Generate augmented data: Since you are handling images, you can upsample the minority class and then use data augmentation on those images, this solves the class imbalance as well as tackles overfitting and improves generalisation.
  4. and Combination of all the above.
Vijay Mariappan
  • 16,921
  • 3
  • 40
  • 59
  • I like your answer @vijay. I wonder if (3.) can be harmful when data augmentation is only applied to underrepresented classes. Does the distortion in distribution pose a risk to the classifiers performance? – Gegenwind Mar 20 '18 at 08:14
  • @Gegenwind what i meant is upsample under-represented classes and then apply data augmentation for all class. – Vijay Mariappan Mar 20 '18 at 15:37