【问题标题】:How to use Smote with imblearn?如何将 Smote 与 imblearn 一起使用?
【发布时间】:2018-12-04 11:41:46
【问题描述】:

我无法将 SMOTE 与 imblearn 一起使用。下面是我在我的 jupyter 笔记本中所做的。有什么建议吗?

pip install -U imbalanced-learn
#installs successfully
!python -V
#2.7.6
imblearn.__version__
#0.3.0
from imblearn.over_sampling import SMOTE
sm = SMOTE()

这里会抛出错误:

    TypeError                                 Traceback (most recent call last)
<ipython-input-73-0715e331ee1b> in <module>()
      1 from imblearn.over_sampling import SMOTE
----> 2 sm = SMOTE()

/home/pradeep/Envs/nyraml/local/lib/python2.7/site-packages/imblearn/over_sampling/smote.pyc in __init__(self, ratio, random_state, k, k_neighbors, m, m_neighbors, out_step, kind, svm_estimator, n_jobs)
    164                  svm_estimator=None,
    165                  n_jobs=1):
--> 166         super(SMOTE, self).__init__(ratio=ratio, random_state=random_state)
    167         self.kind = kind
    168         self.k = k

TypeError: super(type, obj): obj must be an instance or subtype of type
    enter code here

【问题讨论】:

  • 最新版本是0.3.3。也许尝试升级到那个。

标签: python python-2.7 inheritance scikit-learn imblearn


【解决方案1】:

您需要使用 Anaconda 提示符安装 imblearn,而不是使用传统的 pip 方法。我自己也面临同样的问题,不得不去寻找解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-27
    • 2021-04-20
    • 2021-08-28
    • 1970-01-01
    • 2019-08-23
    • 2019-10-01
    • 2021-06-28
    • 2019-03-23
    相关资源
    最近更新 更多