1
$\begingroup$

I wanna install smote from imblearn package and I got the Following error:

ImportError                               Traceback (most recent call last)
<ipython-input-10-77606507c62c> in <module>()
     66 len(data[data["num"]==0])
     67 #balancing dataset
---> 68 from imblearn.over_sampling import SMOTE
     69 import matplotlib.pyplot as plt
     70 sm = SMOTE(random_state=42)

~\Anaconda3\lib\site-packages\imblearn\__init__.py in <module>()
     33 """
     34 
---> 35 from .base import FunctionSampler
     36 from ._version import __version__
     37 

~\Anaconda3\lib\site-packages\imblearn\base.py in <module>()
     17 from sklearn.utils import check_X_y
     18 
---> 19 from .utils import check_sampling_strategy, check_target_type
     20 from .utils.deprecation import deprecate_parameter
     21 

~\Anaconda3\lib\site-packages\imblearn\utils\__init__.py in <module>()
      5 from ._docstring import Substitution
      6 
----> 7 from ._validation import check_neighbors_object
      8 from ._validation import check_target_type
      9 from ._validation import check_ratio

~\Anaconda3\lib\site-packages\imblearn\utils\_validation.py in <module>()
     12 
     13 from sklearn.base import clone
---> 14 from sklearn.neighbors.base import KNeighborsMixin
     15 from sklearn.neighbors import NearestNeighbors
     16 from sklearn.externals import six

~\Anaconda3\lib\site-packages\sklearn\neighbors\__init__.py in <module>()
      7 from .kd_tree import KDTree
      8 from .dist_metrics import DistanceMetric
----> 9 from .graph import kneighbors_graph, radius_neighbors_graph
     10 from .unsupervised import NearestNeighbors
     11 from .classification import KNeighborsClassifier, RadiusNeighborsClassifier

~\Anaconda3\lib\site-packages\sklearn\neighbors\graph.py in <module>()
      5 # License: BSD 3 clause (C) INRIA, University of Amsterdam
      6 
----> 7 from .base import KNeighborsMixin, RadiusNeighborsMixin
      8 from .unsupervised import NearestNeighbors
      9 

~\Anaconda3\lib\site-packages\sklearn\neighbors\base.py in <module>()
     20 from .kd_tree import KDTree
     21 from ..base import BaseEstimator
---> 22 from ..metrics import pairwise_distances_chunked
     23 from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS
     24 from ..utils import check_X_y, check_array, gen_even_slices

ImportError: cannot import name 'pairwise_distances_chunked' from 'sklearn.metrics' (C:\Users\ASUS\Anaconda3\lib\site-packages\sklearn\metrics\__init__.py)
$\endgroup$
3
$\begingroup$

Try closing and restarting ipython. imblearn requires scikit-learn >= 0.20 and sometimes the runtime loads in an older version of scikit-learn.

If the issue still persists, then reinstall all packages together to make sure they are compatible.

| improve this answer | |
$\endgroup$
  • $\begingroup$ I was getting a different import error with SMOTE and this worked for that as well. $\endgroup$ – TrentWoodbury Apr 6 at 12:27
0
$\begingroup$

You can use:

conda install -c conda-forge imbalanced-learn

to reinstall it. This solved my problem.

| improve this answer | |
$\endgroup$
-1
$\begingroup$
pip install Tensorflow

then,

pip install imblearn 

After the installation restart the system, as The imblearn.tensorflow provides utilities to deal with imbalanced dataset in tensorflow, and imblearn uses Tensorflow as backend.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.