I installed "imbalanced-learn" (version 0.3.1) on ANACONDA Navigator. When I ran an example from the imbalanced-learn website using Jupyter (Python 3), I got an message regarding "ModuleNotFoundError". No module named 'imblearn".
from imblearn.datasets import make_imbalance
from imblearn.under_sampling import NearMiss
from imblearn.pipeline import make_pipeline
from imblearn.metrics import classification_report_imbalanced
How could I resolve this?
The Python "ModuleNotFoundError: No module named 'imblearn'" occurs when we forget to install the imbalanced-learn module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install -U imbalanced-learn command.
Type in jupyter notebook in the terminal. Open a new notebook and import sys . The important step is to add the path of your virtual environment site packages to the system path. The ./ is a relative path and assumes that you are currently in your virtual environment directory.
From source available on GitHub Use the following commands to get a copy from Github and install all dependencies: git clone https://github.com/scikit-learn-contrib/imbalanced-learn.git cd imbalanced-learn pip install . Be aware that you can install in developer mode with: pip install --no-build-isolation --editable .
This worked for me:
!pip install imblearn
Then, I was able to import SMOTE
package.
from imblearn.over_sampling import SMOTE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With