imblearn包
from imblearn.over_sampling import SMOTE
from imblearn.combine import SMOTEENN
代码
smo = SMOTE(random_state=42)
x_train, y_train = smo.fit_sample(x_train, y_train)
smo = SMOTEENN(random_state=42)
x_train, y_train = smo.fit_sample(x_train, y_train)