在ipython笔记本上导入imblearn python包的问题

ugr*_*ath 5 python powershell python-2.7 jupyter-notebook imblearn

我安装https://github.com/glemaitre/imbalanced-learn使用上的Windows PowerShell pip install,condagithub.但当我在iPython笔记本上时,我尝试使用以下方法导入包:

from unbalanced_dataset import UnderSampler, OverSampler, SMOTE
Run Code Online (Sandbox Code Playgroud)

我收到错误:


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
Run Code Online (Sandbox Code Playgroud)

使用Windows for Python的新手,我是否必须在某个文件夹中安装该软件包?

小智 8

如果它不起作用,也许你需要安装"imblearn"包.

尝试安装:

  • PIP: pip install -U imbalanced-learn
  • 水蟒: conda install -c glemaitre imbalanced-learn

然后尝试在您的文件中导入库:

  • from imblearn.over_sampling import SMOTE

  • “pip”解决方案在 Jupyter 笔记本中有效。谢谢。 (2认同)

est*_*pdl 6

尝试这个:

from imblearn import under_sampling, over_sampling
Run Code Online (Sandbox Code Playgroud)

为了导入SMOTE

from imblearn.over_sampling import SMOTE
Run Code Online (Sandbox Code Playgroud)

或数据集:

from imblearn.datasets import ...
Run Code Online (Sandbox Code Playgroud)