0

我正在尝试在我的 jupyter 笔记本中导入 SMOTE。我尝试了以下步骤;

我首先在终端中使用以下命令安装了 imblearn

conda install -c glemaitre imbalanced-learn

然后我使用以下命令在我的笔记本中导入 imblearn;

from imblearn import under_sampling, over_sampling

我收到以下错误;

    <ipython-input-36-d0524665b8f2> in <module>()
----> 1 from imblearn import under_sampling, over_sampling

~/anaconda3/lib/python3.6/site-packages/imblearn/under_sampling/__init__.py in <module>()
      4 """
      5 
----> 6 from .prototype_generation import ClusterCentroids
      7 
      8 from .prototype_selection import RandomUnderSampler

~/anaconda3/lib/python3.6/site-packages/imblearn/under_sampling/prototype_generation/__init__.py in <module>()
      4 """
      5 
----> 6 from .cluster_centroids import ClusterCentroids
      7 
      8 __all__ = [

~/anaconda3/lib/python3.6/site-packages/imblearn/under_sampling/prototype_generation/cluster_centroids.py in <module>()
     12 from scipy import sparse
     13 
---> 14 from sklearn.cluster import KMeans
     15 from sklearn.neighbors import NearestNeighbors
     16 from sklearn.utils import safe_indexing

~/anaconda3/lib/python3.6/site-packages/sklearn/cluster/__init__.py in <module>()
      4 """
      5 
----> 6 from .spectral import spectral_clustering, SpectralClustering
      7 from .mean_shift_ import (mean_shift, MeanShift,
      8                           estimate_bandwidth, get_bin_seeds)

~/anaconda3/lib/python3.6/site-packages/sklearn/cluster/spectral.py in <module>()
     15 from ..metrics.pairwise import pairwise_kernels
     16 from ..neighbors import kneighbors_graph
---> 17 from ..manifold import spectral_embedding
     18 from .k_means_ import k_means
     19 

~/anaconda3/lib/python3.6/site-packages/sklearn/manifold/__init__.py in <module>()
      4 
      5 from .locally_linear import locally_linear_embedding, LocallyLinearEmbedding
----> 6 from .isomap import Isomap
      7 from .mds import MDS, smacof
      8 from .spectral_embedding_ import SpectralEmbedding, spectral_embedding

~/anaconda3/lib/python3.6/site-packages/sklearn/manifold/isomap.py in <module>()
      9 from ..utils import check_array
     10 from ..utils.graph import graph_shortest_path
---> 11 from ..decomposition import KernelPCA
     12 from ..preprocessing import KernelCenterer
     13 

~/anaconda3/lib/python3.6/site-packages/sklearn/decomposition/__init__.py in <module>()
      9 from .incremental_pca import IncrementalPCA
     10 from .kernel_pca import KernelPCA
---> 11 from .sparse_pca import SparsePCA, MiniBatchSparsePCA
     12 from .truncated_svd import TruncatedSVD
     13 from .fastica_ import FastICA, fastica

~/anaconda3/lib/python3.6/site-packages/sklearn/decomposition/sparse_pca.py in <module>()
      9 from ..utils import check_random_state, check_array
     10 from ..utils.validation import check_is_fitted
---> 11 from ..linear_model import ridge_regression
     12 from ..base import BaseEstimator, TransformerMixin
     13 from .dict_learning import dict_learning, dict_learning_online

~/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/__init__.py in <module>()
     10 # complete documentation.
     11 
---> 12 from .base import LinearRegression
     13 
     14 from .bayes import BayesianRidge, ARDRegression

~/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/base.py in <module>()
     25 
     26 from ..externals import six
---> 27 from ..utils import Parallel, delayed
     28 from ..base import BaseEstimator, ClassifierMixin, RegressorMixin
     29 from ..utils import check_array, check_X_y

ImportError: cannot import name 'Parallel

谁能指导我?谢谢!

4

1 回答 1

0

因此,在我使用以下步骤安装 SMOTE 后它起作用了;

pip install -U imbalanced-learn
conda install -c conda-forge imbalanced-learn

看起来我安装不正确。

我无法理解以前安装中的错误。如果有人能向我指出这些错误,我将不胜感激。

谢谢!

于 2018-10-20T21:54:00.013 回答