AttributeError: 'SMOTE' object has no attribute 'fit_sample'

AttributeError: 'SMOTE' object has no attribute 'fit_sample'

你好谁能帮助我为什么会收到 AttributeError: 'SMOTE' object has no attribute 'fit_sample' 错误?我不认为这段代码会导致任何错误?谢谢

from imblearn.over_sampling import SMOTE
smt = SMOTE(random_state=0)
X_train_SMOTE, y_train_SMOTE = smt.fit_sample(X_train, y_train)

如果你这样导入

from imblearn.over_sampling import SMOTE

你需要做fit_resample()

oversample = SMOTE()
X, y = oversample.fit_resample(X, y)