我想运行这个关于1D高斯混合的例子:http://www.astroml.org/book_figures/chapter4/fig_GMM_1D.html,但我一直都有这个错误:
from sklearn.mixture import GMM
ImportError: cannot import name 'GMM'
我试图用来自sklearn.mixture import GaussianMixture
的代码替换它,但代码不起作用,它们没有相同的功能。
提前谢谢你。
发布于 2019-04-23 03:10:40
较新版本的scikit-learn没有该模块。从版本来看,它在0.18版本中被弃用,并在0.20版本中被删除。这是到旧的0.18模块的链接,这是我能找到的第一个显示弃用警告的实例。https://scikit-learn.org/0.18/modules/generated/sklearn.mixture.GMM.html#sklearn.mixture.GMM如果你愿意,你可以安装一个旧版本的pip install -Iv scikit-learn==0.15
,或者如果你想使用新版本,调整你的GaussianMixture的参数以反映它们的新名称(例如,在GaussianMixture中,max_iter
是迭代次数,而不是n_iter
)。
https://stackoverflow.com/questions/55799601
复制相似问题