I am trying to build an ensemble model to classify dataset with imbalanced data, where some of classes have just a few samples. And, because of this dataset property, when I am doing re-sampling with replacement, some of classes become "discarded", i.e. there is no samples belonging to these small-sized classes in bootstrapped dataset.

Is there any solution to this issue except original's dataset augmentation/extending? What if I just change bootstrapping process to make sure that all classes are included into bootstrapped dataset? Could it somehow affect the learning process?

Or do you think that in this case one cannot apply bootstrapping at all and should to increase number of samples per class at first?

  • $\begingroup$ Very informative responses both times asking question like this =) Is it a kind of bad taste to ask about imbalanced classes? Could somebody point to a textbook or something to explain this obvious moment then? $\endgroup$
    – devforfu
    Commented May 13, 2018 at 12:14
  • $\begingroup$ Or probably it is a wrong SO domain to ask questions like this? $\endgroup$
    – devforfu
    Commented May 13, 2018 at 12:16
  • 1
    $\begingroup$ This is the right SO, but too much text for most people here. You'll find more help by providing a small example. $\endgroup$
    – tmrlvi
    Commented Jul 29, 2018 at 20:14
  • $\begingroup$ Try oversampling with smote. Python has different types of smote; check which one is applicable and shows the best oob performance. $\endgroup$
    – Shruba
    Commented Jun 29, 2019 at 5:00

1 Answer 1


One method you can try is a form of "stratified"-bootstrap. You can subsample from each group separately, even un-proportionally. Doing so will result in estimation of the empirical distribution of each group, as bootstrap does. Then, to obtain the statistic you want to calculate, you have to weight each sample by its class respective oversampling/undersampling used.

That's the general idea. There seem to be a paper tackling this exact problem. Might worth to go over it.

Maybe this question might also help you, in case you are okay with sampling each class using the original proportion.

  • $\begingroup$ Thank you for the advice! Actually, I have an example of the code but I was thinking as it is not too informative because from my point of view the concept is quite generic and doesn't depend on specific language or model training algorithm :) $\endgroup$
    – devforfu
    Commented Sep 12, 2018 at 12:52

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.