V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
miniketsu
V2EX  ›  Python

请教机器学习 SMOTE 过采样算法的报错问题

  •  
  •   miniketsu · 2019-07-27 10:30:21 +08:00 · 4257 次点击
    这是一个创建于 1728 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在做数据分析过程中给 Anaconda 导入 smote 的包后,使用 SMOTE 的 fit_resample 属性时报错 AttributeError: 'SMOTE' object has no attribute 'fit_resample'。具体情况如下:

    from imblearn.over_sampling import SMOTE
    smote = SMOTE()
    good_train, good_target = smote.fit_resample(X, y)


    AttributeError Traceback (most recent call last)
    <ipython-input-4-e244f10f9936> in <module>
    1 smote = SMOTE()
    ----> 2 good_train, good_target = smote.fit_resample(X, y)

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

    百度了也没有找到答案哇,希望有大神可以帮忙解决一下 /(ㄒoㄒ)/~~
    4 条回复    2019-07-27 12:14:09 +08:00
    dongxiao
        1
    dongxiao  
       2019-07-27 10:49:25 +08:00
    看一下 imblearn 版本,我的 0.5.0 版本没问题,如果版本过低可以升级下看看
    miniketsu
        2
    miniketsu  
    OP
       2019-07-27 11:10:36 +08:00
    @dongxiao
    谢谢啦~我的版本是 0.3.1,尝试升级不过用 pip 和 conda 升级都失败了 /(ㄒoㄒ)/~~

    然后我查了一下官方文档,用 fit_sample 好使了,效果和 fit_resample 一样。所以应该就是版本问题啦。

    btw,可以看看升级失败的解决办法咩~感谢~

    pip 失败原因:’ Could not find a version that satisfies the requirement mblearn (from versions: )
    No matching distribution found for mblearn ‘

    conda 失败原因:’ PackageNotInstalledError: Package is not installed in prefix.
    prefix: D:\softwares\myAnaconda
    package name: imblearn ‘
    dongxiao
        3
    dongxiao  
       2019-07-27 11:21:20 +08:00
    pip 失败原因:*mblearn* 是不是输错了,是*imblearn*才对吧
    miniketsu
        4
    miniketsu  
    OP
       2019-07-27 12:14:09 +08:00 via iPhone
    @dongxiao 啊啊啊对对😂改过来了 虽然还是升不了 但是先不管了 能用就行😂
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   954 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:24 · PVG 06:24 · LAX 15:24 · JFK 18:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.