I am dealing with a binary image classifier. I'm using a CNN to predict if an image is positive or negative. The problem is that the positive class represents only the 2% of the total samples. In this case, I can get lots of images, so that is not a problem. My question is about what is the best option to set up the dataset. One option is to have an unbalanced dataset, if it is extremely unbalanced like this case, the net won't learn, it'would only predict the major class. The other option is to artificially balance the data. What I've done is preparing a dataset with a 40% of the positive class and a 60% of the negative class. This dataset does not represent the real problem and is making lose a lot of samples. Is there a better option?



1 Answer 1


Instead of downsampling the dataset, you should try using the Upsampling technique. Sometime downsampling leads to loss of data. Use augmentation techniques to increase the size of your dataset.

  • $\begingroup$ That's what I'd usually do but this is a special case. The images are taken from an industrial camera, this means that the images wold not rotate, change brigthness etc. In this scenario does it makes sense to use data augmentation? $\endgroup$
    – hardsoft
    Commented Sep 4, 2020 at 19:39
  • $\begingroup$ You should at least try this scenario and see the results. And If this won't work then you have to opt for another approach. $\endgroup$
    – Rina
    Commented Sep 8, 2020 at 4:05
  • $\begingroup$ Why change the class ratio? $\endgroup$
    – Dave
    Commented Oct 9, 2021 at 1:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.