1

我尝试在我的 MAC 上导入 ADASYN。但这里有一些我无法解决的问题。我的代码:

from imblearn.over_sampling import ADASYN

问题是:

ImportError                               Traceback (most recent call last)
<ipython-input-89-48cae80b06ea> in <module>
----> 1 from imblearn.over_sampling import ADASYN

//anaconda3/lib/python3.7/site-packages/imblearn/__init__.py in <module>
     32     Module which allowing to create pipeline with scikit-learn estimators.
     33 """
---> 34 from . import combine
     35 from . import ensemble
     36 from . import exceptions

//anaconda3/lib/python3.7/site-packages/imblearn/combine/__init__.py in <module>
      3 """
      4 
----> 5 from ._smote_enn import SMOTEENN
      6 from ._smote_tomek import SMOTETomek
      7 

//anaconda3/lib/python3.7/site-packages/imblearn/combine/_smote_enn.py in <module>
      8 from sklearn.utils import check_X_y
      9 
---> 10 from ..base import BaseSampler
     11 from ..over_sampling import SMOTE
     12 from ..over_sampling.base import BaseOverSampler

//anaconda3/lib/python3.7/site-packages/imblearn/base.py in <module>
     14 from sklearn.utils.multiclass import check_classification_targets
     15 
---> 16 from .utils import check_sampling_strategy, check_target_type
     17 from .utils._validation import ArraysTransformer
     18 

//anaconda3/lib/python3.7/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_sampling_strategy

//anaconda3/lib/python3.7/site-packages/imblearn/utils/_validation.py in <module>
     11 
     12 from sklearn.base import clone
---> 13 from sklearn.neighbors._base import KNeighborsMixin
     14 from sklearn.neighbors import NearestNeighbors
     15 from sklearn.utils import column_or_1d

//anaconda3/lib/python3.7/site-packages/sklearn/neighbors/_base.py in <module>
     25 from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS
     26 from ..utils import check_X_y, check_array, gen_even_slices
---> 27 from ..utils import _to_object_array
     28 from ..utils.multiclass import check_classification_targets
     29 from ..utils.validation import check_is_fitted

ImportError: cannot import name '_to_object_array' from 'sklearn.utils' (//anaconda3/lib/python3.7/site-packages/sklearn/utils/__init__.py)``` 
4

1 回答 1

0

将您的 sklearn 包更新到更新版本

于 2020-04-11T16:20:31.720 回答