ModuleNotFoundError:没有名为“ imblearn”的模块

mat*_*ver 5 pip machine-learning python-3.x imblearn

我尝试运行以下代码:

from imblearn import under_sampling, over_sampling
from imblearn.over_sampling import SMOTE

sm = SMOTE(random_state=12, ratio = 1.0)
x_SMOTE, y_SMOTE = sm.fit_sample(X, y) 
Run Code Online (Sandbox Code Playgroud)

这给我错误信息:

ModuleNotFoundError: No module named 'imblearn'
Run Code Online (Sandbox Code Playgroud)

我尝试以多种方式安装imblearn模块,它们似乎都可以工作(安装过程中未出现任何错误,但是当我运行上述代码时,出现错误消息)。

我使用其他stackoverflow问题中建议的以下内容尝试了taltaling imblearn:

pip install -U imbalanced-learn
pip install imblearn
!pip install imblearn
pip install -c glemaitre imbalanced-learn
pip install imblearn==0.0
Run Code Online (Sandbox Code Playgroud)

这些似乎都无济于事...有什么想法吗?谢谢!

Ash*_*man 17

我安装了imblearn使用 anaconda 命令提示符命名的模块。

conda install -c conda-forge imbalanced-learn
Run Code Online (Sandbox Code Playgroud)

然后导入包

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

再次,我尝试imblearn通过 pip安装,它对我有用。

(base) C:\WINDOWS\system32>pip install -U imbalanced-learn
Requirement already up-to-date: imbalanced-learn in c:\users\ashok\anaconda3\lib\site-packages (0.4.3)
Requirement already satisfied, skipping upgrade: numpy>=1.8.2 in c:\users\ashok\anaconda3\lib\site-packages (from imbalanced-learn) (1.15.3)
Requirement already satisfied, skipping upgrade: scipy>=0.13.3 in c:\users\ashok\anaconda3\lib\site-packages (from imbalanced-learn) (0.19.1)
Requirement already satisfied, skipping upgrade: scikit-learn>=0.20 in c:\users\ashok\anaconda3\lib\site-packages (from imbalanced-learn) (0.20.0)
Run Code Online (Sandbox Code Playgroud)


小智 12

在 AWS SageMaker 上,请按照文档操作:

!pip install imbalanced-learn
Run Code Online (Sandbox Code Playgroud)

在笔记本单元中。


小智 5

这对我有用

  1. 首先在您的环境中安装该软件包:
pip install -U imbalanced-learn
Run Code Online (Sandbox Code Playgroud)
  1. 下一个:
conda install -c conda-forge imbalanced-learn
Run Code Online (Sandbox Code Playgroud)


kro*_*516 0

尝试这样:

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

或者

import imblearn *
Run Code Online (Sandbox Code Playgroud)