I have a training data set with class 0 and class 1. The data set is highly imbalanced as the ratio of class 0 to class 1 records is ~12. I want to generate a balanced training data set by selecting all class 1 records and the same number of class 0 records. How to get this done in Python?