python - 属性错误 : 'SMOTE' object has no attribute 'fit_sample'

标签 python python-3.x imblearn

嗨,谁能帮助我为什么我收到 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)

关于python - 属性错误 : 'SMOTE' object has no attribute 'fit_sample' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66364406/

相关文章:

具有列表本地和全局范围的 Python 奇怪的东西

具有混合数据类型的 Python 嵌套 defaultdict

string - Hackerrank `super-functional-strings` 因超时而终止

python - 通过替换字符串的一部分来重命名多个文件夹中的子文件夹

python-3.x - 当没有异常处于事件状态时,Python 3 回溯失败

python-3.x - ValueError : Found array with dim 3. 估计器在随机欠采样期间预计 <= 2

Python 过采样在管道中组合了多个采样器

python - 限制 matplotlib 热图中的列

Python - 解析带有自定义价格单位的字符串

python-3.x - Jupyter : No module named 'imblearn" after installation