我一直在跟随这里的PyMC3高斯混合模型示例:https://github.com/pymc-devs/pymc3/blob/master/pymc3/examples/gaussian_mixture_model.ipynb,并已经成功地将其与人造数据集配合使用。
我尝试了一个真实数据集,但是我很难让它给出合理的结果:
有什么想法可以缩小/扩大/改变哪些参数以获得更好的拟合?迹线似乎很稳定。这是我从示例中调整的模型片段:
![enter image description here](https://istack.dev59.com/xBWUE.webp)
![enter image description here](https://istack.dev59.com/Yh5jf.webp)
model = pm.Model()
with model:
# cluster sizes
a = pm.constant(np.array([1., 1., 1.]))
p = pm.Dirichlet('p', a=a, shape=k)
# ensure all clusters have some points
p_min_potential = pm.Potential('p_min_potential', tt.switch(tt.min(p) < .1, -np.inf, 0))
# cluster centers
means = pm.Normal('means', mu=[0, 1.5, 3], sd=1, shape=k)
# break symmetry
order_means_potential = pm.Potential('order_means_potential',
tt.switch(means[1]-means[0] < 0, -np.inf, 0)
+ tt.switch(means[2]-means[1] < 0, -np.inf, 0))
# measurement error
sd = pm.Uniform('sd', lower=0, upper=2, shape=k)
# latent cluster of each observation
category = pm.Categorical('category', p=p, shape=ndata)
# likelihood for each observed value
points = pm.Normal('obs', mu=means[category], sd=sd[category], observed=data)