0
$\begingroup$

I am looking to get an unbalanced training set with a given ratio of classA:classB from a dataset without regarding if it is balanced or not. The point is to analyze the influence of data imbalance on the accuracy. I don't see any built-in function to go about this, so I was wondering what approach I should take. For now, I consider either undersampling or oversampling, but I am worried that it might skew the results too much, as I aim to get class ratios of 10/90, 20/80, ..., 80/20, 90/10.

$\endgroup$
1
  • $\begingroup$ You can use pandas to create a dataset with the ratio you want between class A and class B labels $\endgroup$
    – Oscar
    Apr 9, 2021 at 9:27

1 Answer 1

0
$\begingroup$

With a straightforward approach, you can just oversample one of the classes to get the imbalance. You can achieve it with using SMOTE for example. Usually this technique is used to get a balanced set from imbalanced, but it can also work vice-versa, just oversample only once class.

Some links to check:

https://imbalanced-learn.org/stable/over_sampling.html https://machinelearningmastery.com/random-oversampling-and-undersampling-for-imbalanced-classification/ https://towardsdatascience.com/how-to-effortlessly-handle-class-imbalance-with-python-and-smote-9b715ca8e5a7

$\endgroup$

Your Answer

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

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