Unbalanced training set from balanced data

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.

• You can use pandas to create a dataset with the ratio you want between class A and class B labels – Oscar Apr 9 at 9:27

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.