在 ipython notebook 上导入 imblearn python 包的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40008015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problems importing imblearn python package on ipython notebook
提问by ugradmath
I installed https://github.com/glemaitre/imbalanced-learnon windows powershell using pip install
, conda
and github
. But when I'm on iPython notebook and I tried to import the package using:
我安装https://github.com/glemaitre/imbalanced-learn在Windows PowerShell上使用pip install
,conda
和github
。但是当我在 iPython 笔记本上时,我尝试使用以下方法导入包:
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?
刚开始使用 windows for Python,我是否必须将软件包安装在某个文件夹中?
回答by Vito Trentadue
If it don't work, maybe you need to install "imblearn" package.
如果它不起作用,也许您需要安装“imblearn”包。
Try to install:
尝试安装:
- pip:
pip install -U imbalanced-learn
- anaconda:
conda install -c glemaitre imbalanced-learn
- 点:
pip install -U imbalanced-learn
- 蟒蛇:
conda install -c glemaitre imbalanced-learn
Then try to import library in your file:
然后尝试在您的文件中导入库:
from imblearn.over_sampling import SMOTE
from imblearn.over_sampling import SMOTE
回答by estebanpdl
Try this:
尝试这个:
from imblearn import under_sampling, over_sampling
In order to import SMOTE
:
为了导入SMOTE
:
from imblearn.over_sampling import SMOTE
Or datasets:
或数据集:
from imblearn.datasets import ...
回答by Ragni Sah
Type !pip install imblearn
输入 !pip install imblearn
in jupyter notebook. this worked for me.
在 jupyter 笔记本中。这对我有用。
回答by Marwa Ahmed
I've tried all of these solutions and nothing worked, only thing that worked for me is changing the kernel. I'm running Jupyter on Amazon Sagemaker and I changed the kernel from pyhton3 to pytorch36 and it worked just fine. Hope this helps
我已经尝试了所有这些解决方案,但没有任何效果,唯一对我有用的是更改内核。我在 Amazon Sagemaker 上运行 Jupyter,并将内核从 pyhton3 更改为 pytorch36,并且运行良好。希望这可以帮助
回答by Ben S
pip install -U imbalanced-learn
should work, although make sure you've met the dependencies for numpy, scipy and scikit-learn.
pip install -U imbalanced-learn
应该可以工作,但请确保您已满足 numpy、scipy 和 scikit-learn 的依赖项。