在Python中实现贝叶斯分层建模。

问题描述 投票:-1回答:1

我正试图在不同的数据集上实现贝叶斯层次建模,我通过互联网搜索,发现了Pymc3的这个文档。

https:/docs.pymc.ionotebooksGLM-hierarchical.html。

我想知道,他们到底是如何使用这些参数的。缪值,西格玛值,为什么他们使用这些值。是如何确定的?

以下是用于氡数据集的代码。

with pm.Model() as hierarchical_model:
    # Hyperpriors for group nodes
    mu_a = pm.Normal('mu_a', mu=0., sigma=100)
    sigma_a = pm.HalfNormal('sigma_a', 5.)
    mu_b = pm.Normal('mu_b', mu=0., sigma=100)
    sigma_b = pm.HalfNormal('sigma_b', 5.)

    # Intercept for each county, distributed around group mean mu_a
    # Above we just set mu and sd to a fixed value while here we
    # plug in a common group distribution for all a and b (which are
    # vectors of length n_counties).
    a = pm.Normal('a', mu=mu_a, sigma=sigma_a, shape=n_counties)
    # Intercept for each county, distributed around group mean mu_a
    b = pm.Normal('b', mu=mu_b, sigma=sigma_b, shape=n_counties)
machine-learning pymc3 pymc hierarchical-bayesian
1个回答
0
投票

从你的博文中。

我们假设截距α和斜率β来自于正态分布 围绕着各自的组均值μ有一定的标准差σ^2。

这意味着模型假设countys并不完全相似,但它们也不是完全独立的.参数μ(μ)和σ^2(sigma)代表每个县之间的相似度。如果我们再读一下你发的文章,就会看到这句话。

mu_a告诉我们组的平均氡水平。 mu_b告诉我们,没有地下室会显著降低氡水平(质量不超过零)。

所以这就是mu_a和mu_b所代表的。Sigma_a和sigma_b将代表数据的方差。如果你不熟悉这些术语,那么你可能想阅读维基百科上的网页。正态分布.

我对这个算法不熟悉,但似乎他们只是通过选择随机数或他们知道通常是算法的良好起点的数字来确定μ和sigma的值。mu和sigma的值都会改变,以更好地适应模型所看到的数据。

© www.soinside.com 2019 - 2024. All rights reserved.