Problems importing imblearn python package on ipython notebook

有些话、适合烂在心里 提交于 2019-12-01 04:18:09

问题


I installed https://github.com/glemaitre/imbalanced-learn on windows powershell using pip install, conda and github. But when I'm on iPython notebook and I tried to import the package using:

from unbalanced_dataset import UnderSampler, OverSampler, SMOTE

I get the error:


ImportError  Traceback (most recent call last) <ipython-input-9-ad6fd7440a05> in <module>()
----> 1 from imbalanced_learn import UnderSampler, OverSampler, SMOTE

ImportError: No module named imbalanced_learn

New to using windows for Python, do I have to install the package in some folder?


回答1:


If it don't work, maybe you need to install "imblearn" package.

Try to install:

  • pip: pip install -U imbalanced-learn
  • anaconda: conda install -c glemaitre imbalanced-learn

Then try to import library in your file:

  • from imblearn.over_sampling import SMOTE



回答2:


Try this:

from imblearn import under_sampling, over_sampling

In order to import SMOTE:

from imblearn.over_sampling import SMOTE

Or datasets:

from imblearn.datasets import ...



回答3:


Type !pip install imblearn

in jupyter notebook. this worked for me.




回答4:


pip install -U imbalanced-learn should work, although make sure you've met the dependencies for numpy, scipy and scikit-learn.

Imbalanced-learn 0.3.0 Install Documentation



来源:https://stackoverflow.com/questions/40008015/problems-importing-imblearn-python-package-on-ipython-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!