gpt4 book ai didi

python - ImportError : cannot import name choice when importing sklearn. 混合物

转载 作者:太空狗 更新时间:2023-10-29 23:55:01 28 4
gpt4 key购买 nike

我正在使用 scikit learn 0.15.0。当我尝试导入 sklearn.mixture 时,我得到ImportError: 无法导入名称选择

有什么想法吗?

============================================= ====================

In [1]: **from sklearn import mixture**

ImportError Traceback (most recent call last)
<ipython-input-1-05bc76cab98d> in <module>()
----> 1 from sklearn import mixture

/home/f/anaconda/lib/python2.7/site-packages/sklearn/mixture/__init__.py in <module>()
3 """
4
----> 5 from .gmm import sample_gaussian, log_multivariate_normal_density
6 from .gmm import GMM, distribute_covar_matrix_to_match_covariance_type
7 from .gmm import _validate_covars

/home/f/anaconda/lib/python2.7/site-packages/sklearn/mixture/gmm.py in <module>()
16 from ..utils import check_random_state, deprecated
17 from ..utils.extmath import logsumexp, pinvh
---> 18 from .. import cluster
19
20 from sklearn.externals.six.moves import zip

/home/f/anaconda/lib/python2.7/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, estimate_bandwidth, \
8 get_bin_seeds

/home/f/anaconda/lib/python2.7/site-packages/sklearn/cluster/spectral.py in <module>()
16 from ..neighbors import kneighbors_graph
17 from ..manifold import spectral_embedding
---> 18 from .k_means_ import k_means
19
20

/home/f/anaconda/lib/python2.7/site-packages/sklearn/cluster/k_means_.py in <module>()
28 from ..utils import as_float_array
29 from ..utils import gen_batches
---> 30 from ..utils.random import choice
31 from ..externals.joblib import Parallel
32 from ..externals.joblib import delayed

ImportError: cannot import name choice

最佳答案

from sklearn.mixture import GaussianMixture

使用它可以更具体地使用 .gmm,

from sklearn.cluster import KMeans

对于:

     16 from ..neighbors import kneighbors_graph
17 from ..manifold import spectral_embedding
---> 18 from .k_means_ import k_means

关于python - ImportError : cannot import name choice when importing sklearn. 混合物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25001270/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com