Problems importing imblearn python package on ipython notebook

61,624

Solution 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

Solution 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 ...

Solution 3

Type !pip install imblearn

in jupyter notebook. this worked for me.

Share:
61,624
ugradmath
Author by

ugradmath

Updated on July 28, 2022

Comments

  • ugradmath
    ugradmath almost 2 years

    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?

  • bernando_vialli
    bernando_vialli about 6 years
    hi, I have taken those steps that you suggested and it still does not work. Any ideas?
  • Marjan Radfar
    Marjan Radfar about 3 years
    The "pip" solution worked in the Jupyter notebook. Thanks.