小编Ale*_*lia的帖子

作为 PC 算法的一部分,在 Python 中测试条件独立性

我正在用 python 实现 PC 算法。该算法构建了n变量高斯分布的图形模型。该图模型基本上是有向无环图的骨架,这意味着如果结构如下:

(x1)---(x2)---(x3)
Run Code Online (Sandbox Code Playgroud)

是在图中,则给定 x2,x1 与 x3 无关。更一般地,如果 A 是图的邻接矩阵并且 A(i,j)=A(j,i) = 0 (i 和 j 之间缺少边),则 i 和 j 是条件独立的,对于所有变量出现在从 i 到 j 的任何路径中。出于统计和机器学习的目的,可以“学习”底层图形模型。如果我们对联合高斯 n 变量随机变量有足够的观察,我们可以使用 PC 算法,其工作原理如下:

given n as the number of variables observed, initialize the graph as G=K(n) 
for each pair i,j of nodes:
    if exists an edge e from i to j:
        look for the neighbours of i
        if j is in neighbours of i then remove j from the set of …
Run Code Online (Sandbox Code Playgroud)

python statistics machine-learning bayesian-networks directed-acyclic-graphs

5
推荐指数
1
解决办法
3401
查看次数