【发布时间】:2019-08-03 23:33:25
【问题描述】:
我对 python 和 GMM 真的很陌生。我最近学习了 GMM,并尝试实现 here 的代码
我在运行 gmm.sample() 方法时遇到了一些问题:
gmm16 = GaussianMixture(n_components=16, covariance_type='full', random_state=0)
Xnew = gmm16.sample(400,random_state=42)
plt.scatter(Xnew[:, 0], Xnew[:, 1])
错误显示:
TypeError: sample() got an unexpected keyword argument 'random_state'
我检查了最新的文档,发现方法 sample 应该只包含 n ,表示要生成的样本数。但是当我删除 'random_state=42' 时,会出现新的错误:
代码:
Xnew = gmm16.sample(400)
plt.scatter(Xnew[:, 0], Xnew[:, 1])
错误:
TypeError: tuple indices must be integers or slices, not tuple
在您实现 Jake VanderPlas 的代码时,是否有人遇到过这个问题?我该如何解决?
我的 Jupyter:
笔记本服务器版本为:5.7.4
Python 3.7.1(默认,2018 年 12 月 14 日,13:28:58)
输入“版权”、“信用”或“许可”以获取更多信息
IPython 7.2.0 -- 增强的交互式 Python。类型 '?'寻求帮助。
【问题讨论】:
标签: python scikit-learn data-science gaussian mixture-model