SMOTE/SMOTEEN 处理不平衡数据集

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)

你可能感兴趣的:(python)