9

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?

sophros
  • 14,672
  • 11
  • 46
  • 75
ugradmath
  • 107
  • 1
  • 1
  • 4

8 Answers8

13

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
Vito Trentadue
  • 131
  • 1
  • 2
6

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 ...
estebanpdl
  • 1,213
  • 1
  • 12
  • 31
2

Type !pip install imblearn

in jupyter notebook. this worked for me.

Ragni Sah
  • 39
  • 2
1

pip3 install imblearn --ignore-installed scikit-learn

just ignore the module causing the version mismatch and proceed with installation. the above command fix the below error. error:

Collecting scikit-learn>=1.1.0 (from imbalanced-learn->imblearn) Could not find a version that satisfies the requirement scikit-learn>=1.1.0 (from imbalanced-learn->imblearn) (from versions: 0.9, 0.10, 0.11, 0.12, 0.12.1, 0.13, 0.13.1, 0.14, 0.14.1, 0.15.0b1, 0.15.0b2, 0.15.0, 0.15.1, 0.15.2, 0.16b1, 0.16.0, 0.16.1, 0.17b1, 0.17, 0.17.1, 0.18, 0.18.1, 0.18.2, 0.19b2, 0.19.0, 0.19.1, 0.19.2, 0.20rc1, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.20.4, 0.21rc2, 0.21.0, 0.21.1, 0.21.2, 0.21.3, 0.22rc2.post1, 0.22rc3, 0.22, 0.22.1, 0.22.2, 0.22.2.post1, 0.23.0rc1, 0.23.0, 0.23.1, 0.23.2, 0.24.dev0, 0.24.0rc1, 0.24.0, 0.24.1, 0.24.2) No matching distribution found for scikit-learn>=1.1.0 (from imbalanced-learn->imblearn)

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 19 '22 at 00:25
0

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

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
Ben S
  • 11
0

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

0

What finally worked for me was putting the venv into the notebook according to Add Virtual Environment to Jupyter Notebook

Here's what I did, using commands from the article:

$ python3 -m pip install --user ipykernel

# add the virtual environment to Jupyter
$ python3 -m ipykernel install --user --name=venv

# create the virtual env in the working directory
$ python3 -m venv ./venv

# activate the venv
$ source venv/bin/activate

# install the package
(venv) pip install imbalanced-learn

# fire up the notebook
(venv) jupyter notebook

belwood
  • 3,320
  • 11
  • 38
  • 45
0

#imblearn issue resolve Same issue I have faced I resolve this issue just doing a small change You should just capitalize the module "Imblearn"

!pip3 install Imblearn import imblearn