I am working on a balanced binary classification problem. I don't need to adjust the proportion of either of the classes, as it's already 50/50 . However, some of the samples are more valuable than others. For example, even though row 4 and row 15 are both response variable = 0, it is actually more valuable to me to get row 4 correct than row 15.

You could say "then your response variable is designed incorrectly", but let's leave that aside for a moment.

Could I use oversampling to increase the prevalence of the "more important" rows in my dataset (by duplicating them), and therefore increasing the weight of those samples so that whichever ML algorithm I'm using is forced to value those examples more heavily?

Is there any other way of going about increasing the sample weight for certain samples?

Thank you!


1 Answer 1


Oversampling is one option. You could also give sample_weights to the ML algorithm (many in scikit-learn accept it in their fit methods), or formulate your loss function explicitly and accordingly.

  • $\begingroup$ I am working in R, and I don't think all of the ML options have a sample_weights parameter :/ But so, oversampling (sampling with replacement from original data, with sample frequency proportional to my desired sample-weight) is a valid approach? $\endgroup$ Mar 1, 2022 at 23:02
  • $\begingroup$ Oversampling in some other way is also an option, not just sampling with replacement. $\endgroup$
    – gunes
    Mar 3, 2022 at 18:56
  • $\begingroup$ I'm sorry, could you explain? I'll be happy to make another question if needed. Doesn't oversampling have to be done by sampling with replacement, since you're sampling a larger number of times than you have rows of data? How could you do it without replacement? $\endgroup$ Mar 4, 2022 at 1:12
  • 1
    $\begingroup$ I meant oversampling in general is not constrained to sampling with or without replacement. $\endgroup$
    – gunes
    Mar 4, 2022 at 9:34

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.