写在最前:
本人只是一个刚开始学习入门的学渣,写的笔记主要给自己看。要是有大佬发现有错误的地方,还望告知斧正。
设计用于在充足的因果假设下(即没有未测量的共同原因和没有选择变量)学习有向无环图(DAGs)。一个DAGs的马尔可夫等价类它可以被一个所谓的完整的部分有向无环图(CPDAG)唯一地描述。
该算法由三个步骤组成。步骤1(也称为邻接搜索)查找骨架和分离集,而步骤2和步骤3确定边缘的方向。
伪代码如下:
Algorithm 3.1 The PC-algorithm (oracle version)
Require: Conditional independence information among all variables in V, and an ordering
order(V) on the variables
1: Adjacency search: Find the skeleton C and separation sets using Algorithm 3.2;
2: Orient unshielded triples in the skeleton C based on the separation sets;
3: In C orient as many of the remaining undirected edges as possible by repeated application
of rules R1-R3 (see text);
4: return Output graph (C) and separation sets (sepset).
算法3.1 PC算法(Oracle版本)
要求:V中所有变量之间的条件独立信息,以及变量上的排序顺序(V)
1. 邻近搜索:使用算法3.2找到骨架C和分离集
2. 根据分离集,在骨架C中定位未屏蔽的三元组(v型结构(Xi,Xj,Xk))
3. 在 C 中,通过重复应用规则 R1-R3(见正文),尽可能多地定位剩余的无向边
4. 返回 输出图(C)和分离集(sepset)
Algorithm 3.2 Adjacency search / Step 1 of the PC-algorithm (oracle version)
Require: Conditional independence information among all variables in V, and an ordering
order(V) on the variables
1: Form the complete undirected graph C on the vertex set V
2: Let l = −1;
3: repeat
4: Let l = l + 1;
5: repeat
6: Select a (new) ordered pair of vertices (Xi, Xj ) that are adjacent in C and satisfy|adj(C, Xi) \ {Xj}| ≥ l , using order(V);
7: repeat
8: Choose a (new) set S ⊆ adj(C, Xi) \ {Xj} with |S| = l , using order(V);
9: if Xi and Xj are conditionally independent given S then
10: Delete edge Xi − Xj from C;
11: Let sepset(Xi, Xj ) = sepset(Xj , Xi) = S;
12: end if
13: until Xi and Xj are no longer adjacent in C or all S ⊆ adj(C, Xi) \ {Xj} with|S| = l have been considered
14: until all ordered pairs of adjacent vertices (Xi, Xj ) in C with |adj(C, Xi) \ {Xj}| ≥ l have been considered
15: until all pairs of adjacent vertices (Xi, Xj ) in C satisfy |adj(C, Xi) \ {Xj}| ≤ l
16: return C, sepset.
当 l = 0 时,测试所有顶点对的边缘独立性。如果是Xi⊥Xj,则删除边Xi−Xj,并将空集保存为(Xi、Xj)和(Xj、Xi)的分离集。在考虑了所有的顶点对之后,算法将使用l=1进入下一步。
当 l = 1 时,算法选择在 C 中仍然相邻的一对有序顶点 (Xi , Xj ),并检查 Xi ⊥ Xj |S 是否成立,S为 adj(C, Xi) \ {Xj} 的大小为 l = 1 的子集 S . 如果找到这样的条件独立,则去除边Xi-Xj,将对应的条件集S保存在Xi、Xj)和(Xj、Xi)的分离集中。如果给定大小为l的所有子集的相邻顶点的所有有序对都已经考虑完毕,则该算法再次将l增加1。这个过程一直持续到当前图中的所有邻接集都小于l为止。此时,已经确定了骨架和分离集。
这个过程确实确保了我们只查询q−1阶的条件独立性,其中q是底层DAG中节点邻接集的最大大小。这使得该算法对于大型稀疏图特别有效。
步骤2确定了v型结构。特别地,它考虑C中的所有未屏蔽三元组,当且仅当Xj不属于(Xi、Xk)分离集时,将未屏蔽三元组(Xi、Xj、Xk)定位为v结构。
最后,步骤3通过重复应用以下三个规则,尽可能多地定位剩余的无向边:
R1:只要存在有向边 Xi → Xj ,将 Xj − Xk 定向为 Xj → Xk,使得 Xi 和 Xk 不相邻(否则会创建新的 v 结构)
R2:只要存在链 Xi → Xk → Xj,就将 Xi - Xj 定向为 Xi → Xj(否则创建有向循环)
R3:当有两条链 Xi - Xk → Xj 和 Xi - Xl → Xj ,使得 Xk 和 Xl 不相邻时,将 Xi - Xj 定向为 Xi → Xj(否则会创建新的 v 结构或有向循环)
Refs:
[1]Colombo D, Maathuis M H. Order-independent constraint-based causal structure learning[J]. J. Mach. Learn. Res., 2014, 15(1): 3741-3782.
PC与PC-Stable之间的主要区别由后5-7行的for循环给出,它计算并存储了每个l条件下所有变量的邻接集a(Xi)。每当我们搜索给定大小的条件集时,都会使用这些存储的邻接集 a(Xi)。因此,第13行上的边删除不再影响在这个级别的上检查其他变量对的条件独立
。
换句话说,在的每个级别上,PC-Stable记录了应该删除哪些边,但为了使用邻接集,它只有当它进入的下一个值时才会删除这些边。除了解决骨架估计中的顺序依赖性外,我们的算法还具有在的各级都易于并行的优点
。
伪代码如下:
Algorithm 3.2 Adjacency search / Step 1 of the PC-algorithm (oracle version)
Require: Conditional independence information among all variables in V, and an ordering
order(V) on the variables
1: Form the complete undirected graph C on the vertex set V
2: Let l = −1;
3: repeat
4: Let l = l + 1;
5: for all vertices Xi in C do
6: Let a(Xi) = adj(C, Xi)
7: end for
8: repeat
9: Select a (new) ordered pair of vertices (Xi, Xj ) that are adjacent in C and satisfy|adj(C, Xi) \ {Xj}| ≥ l , using order(V);
10: repeat
11: Choose a (new) set S ⊆ adj(C, Xi) \ {Xj} with |S| = l , using order(V);
12: if Xi and Xj are conditionally independent given S then
13: Delete edge Xi − Xj from C;
14: Let sepset(Xi, Xj ) = sepset(Xj , Xi) = S;
15: end if
16: until Xi and Xj are no longer adjacent in C or all S ⊆ adj(C, Xi) \ {Xj} with|S| = l have been considered
17: until all ordered pairs of adjacent vertices (Xi, Xj ) in C with |adj(C, Xi) \ {Xj}| ≥ l have been considered
18: until all pairs of adjacent vertices (Xi, Xj ) in C satisfy |adj(C, Xi) \ {Xj}| ≤ l
19: return C, sepset.
Refs:
[1]Colombo D, Maathuis M H. Order-independent constraint-based causal structure learning[J]. J. Mach. Learn. Res., 2014, 15(1): 3741-3782.
与 PC类似,Hiton-PC应用条件独立性测试来识别变量之间的关系,但一种完全不同的方法来减少条件独立性测试的数量:
优先级队
列用于存储与目标变量关联的所有变量,按关联强度的降序排列
。优先级队列中的变量是要添加到 PC 集中的候选者。由于与目标具有更强关联的变量较先测试,因此可以更快地识别非因果变量
。阈值 max~k~ 用于指定要进行的测试的最高顺序
。这是可选的,但是设置后效率会大大提高。算法的输入包括一组预测变量和给定目标变量的数据集,以及两个参数,一个用于限制条件独立性检验的顺序,一个用于条件独立性检验的显着性水平。算法的输出是给定目标变量的父子集。
输入:D,一组预测变量 X = {X1,X2,…,Xm} 和目标变量 Z ; maxk:条件独立性检验的阶阈值;α:显着性水平条件独立性检验。
输出:PC,X 的子集,包含 Z 的父母和孩子。
伪代码如下:
Algorithm 3.1: The HITON-PC algorithm
let PC = Ø
let OPEN contain all variables associated with Z, sorted in descending order of strength of associations.令 OPEN 包含与 Z 关联的所有变量,按关联强度的降序排序。
while OPEN ≠ Ø do
remove the first variable X from OPEN 从OPEN中移除第一个元素
insert X to the end of PC 把OPEN中移除第一个元素插入PC尾端
for each S ⊆ PC \ {X} and |S| ≤ maxk do
if X,Z are independent given S at significance level α α概率X⊥Z|S
then remove X from PC
end if
end for
end while
for each variable X in PC do
for each S ⊂ PC \ {X} and S 不属于 PC<X , where PC<X comprises the elements in PC that were added before X and |S| ≤ maxk do
if X,Z are independent given S at significance level α α概率X⊥Z|S
then remove X from PC
end if
end for
end for
output PC
e.g.
给定 8 个预测变量 A、B、C、D、E、F、G 和 H 以及目标变量 Z,条件独立/依赖关系如图:
Step0. 初始化:OPEN = [B,C,A,G,F],PC = {Ø}.
H, D 和E与Z独立。
Step1. OPEN = [C,A,G,F],PC = {B};
B 从 OPEN 中移除并添加到 PC.。因为PC \ {B}为Ø,不进行条件独立性检验,B保留在PC中。
Step2. OPEN = [A,G,F],PC = {B,C};
从 OPEN 中删除 C 并添加到 PC。因为PC \ {C} = {B},因此进行了以 {B}为条件的条件独立性检验,即Ind(C,Z|B) 。由于Ind(C,Z|B)为假,C 被保存在 PC 中。
Step3. OPEN = [G,F],PC = {B,C,A};
从 OPEN 中删除 A 并添加到 PC。因为PC \ {A} = {B, C},因此进行了以 {B, C}为条件的条件独立性检验,即Ind( A,Z|B)、Ind(A,Z|C) 和 Ind(A,Z|B,C)。由于 Ind(A,Z|B,C)为真,以从 PC 中消除了 A,即 PC = {B,C}。
Step4. OPEN = [F],PC = {B,C,G};
从 OPEN 中删除G并添加到 PC。因为PC \ {G} = {B,C},因此进行了以 {B, C}为条件的条件独立性检验,即Ind(G,Z|B)、Ind(G,Z|C) 和 Ind(G,Z|B,C) 进行测试,由于都为假,C 被保存在 PC 中 ,PC = {B,C,G}。
Step5. OPEN = [ ],PC = {B,C,G,F};
从 OPEN 中删除F并添加到 PC。因为 PC \ {F} = {B,C,G} 和 maxk= 2,因此进行了Ind(F, Z|B), I nd(F,Z|C), I nd(F,Z |D)、I nd(F,Z|B,C)、I nd(F,Z|B,G)、Ind(F,Z|C,G) 的条件独立性检验。没有测试返回真,所以 F 保存在 PC 中并且 PC = {B,C,G,F}。
Step6.OPEN为空,循环终止。
Step7. for 循环使用 PC 中的当前变量 {B,C,G,F}执行;
The max-min parents and children algorithm(MMPC):贝叶斯网络学习算法,是基于局部发现算法称为最大最小父母和孩子(MMPC)。算法名称的Max-Min部分表示算法使用的启发式算法
,而父部分和子部分是算法的输出。
伪代码如下:
procedure MMPC (T,D)
Input: target variable T; data D
Output: the parents and children of T any Bayesian network faithfully representing the data distribution
%Phase I: Forward
CPC = Ø
repeat
<F, assoc)>= MaxMinHeuristic(T; CPC)
if assocF≠ 0 then
CPC= CPCUF
end if
until CPC has not changed
%Phase II: Backward
for all X∈CPC do
if 存在S包含于CPC, s.t. Ind(X;T|S) then
CPC= CPC \{X}
end if
end for
return CPC
end procedure
procedure MAXMINHEURISTIC(T,CPC)
Input: target variable T; subset of variables CPC
输入:目标变量T; 变量 CPC 的子集
Output: the maximum over all variables of the minimum association with T relative to CPC, and the variable that achievesthe maximum
输出:与 T 相关的最小关联的所有变量的最大值(相对于 CPC),以及达到最大值的变量
assocF = max x∈v MinAssoc(X;T|CPC)
F = argmax x∈v MinAssoc(X;T|CPC)
return (F, assocF)
end procedure
e.g.
我们设置一个Rest={}、MinAssocMax={}便于理解。Rest表示图中还没有被检查过是否进入CPC的结点集;MinAssocMax表示以最小关联度为度量排序时的最大值的结点。
Step1. CPC={Ø},Rest={A, B, C, D, E, F, H, I, J, K, L}
对于每个Rest中结点,计算在CPC下T与每个Rest中结点的最小关联度MinAssoc并从大到小排序得到MinAssoc{A, B, C, D, E, F, H, I, J, K, L}(此处为假设)。MinAssocMax表示以最小关联度为度量排序时的最大值的结点A,将A加入CPC,在Rest中剔除A点。
因为(T⊥B|{Ø}),(T⊥E|{Ø}),在Rest中剔除B、E两点。
Rest={C, D, F, H, I, J, K, L}
Step2. CPC={A},Rest={C, D, F, H, I, J, K, L}
对于每个Rest中结点,计算在CPC下T与每个Rest中结点的最小关联度MinAssoc并从大到小排序得到MinAssoc{D, C, F, H, I, J, K, L}。MinAssocMax表示以最小关联度为度量排序时的最大值的结点D,将D加入CPC,在Rest中剔除D点。
因为(T⊥Ø|{A}),在Rest中不剔除点。
Rest={C, F, H, I, J, K, L}
Step3. condition=CPC={A, D},Rest={C, F, H, I, J, K, L}
对于每个Rest中结点,计算在condition下T与每个Rest中结点的最小关联度并从大到小排序得到MinAssoc{C, F, H, I, J, K, L}。MinAssocMax表示以最小关联度为度量排序时的最大值的结点C,将C加入CPC,在Rest中剔除C点。
因为(T⊥H|{D}),(T⊥J|{D}),在Rest中剔除H、J两点。
Rest={F, I, K, L}
)
Step4. condition=CPC={A, D, C},Rest={F, I, K, L}
对于每个Rest中结点,计算在condition下T与每个Rest中结点的最小关联度并从大到小排序得到MinAssoc{I, F, K, L}。MinAssocMax表示以最小关联度为度量排序时的最大值的结点I,将I加入CPC,在Rest中剔除I点。
因为(T⊥F|{C}),在Rest中剔除F点。
Rest={K, L}
)
Step5. condition=CPC={A, D, C, I},Rest={K, L}
因为(T⊥K|{I}),(T⊥L|{I}),在Rest中剔除K、L两点。
Rest={Ø},CPC也不会再改变,结束phase 1。
)
存在返回假阴性情况:
由于 PC 关系应该是对称的,破坏对称性表明存在误报。 MMPC 检查是否所有 X ∈ MMPC(T, D) 的 T ∈ MMPC(X, D) ;如果不是这种情况,它会从其输出中删除 X。
Algorithm 2 Algorithm MMPC
1:procedure MMPC(T,D)
2: CPC=MMPC(T,D)
3: for every variable X ∈ CPCdo
4: if T不属于 MMPC(X,D) then
5: CPC= CPC\x
6: end if
7: end for
8:return CPC
以空集为条件,存在路径 T → A → C,T 和 C d-连接了;以 {A} 为条件,存在路径 T → A ← B → C,T 和 Cd-连接了。d-分离 T 和 C 的唯一方法是同时以 A 和 B 为条件。但是,算法不会以集合 {A, B} 为条件,因为B 将从 CPC 中删除,因为它独立于 T 给定空集。
T的CPC={A, C, D, I},A的CPC={C, D},T不为A的CPC,A为T的CPC,不对称,所以在T的CPC中去掉A。
Refs:
[1]Tsamardinos I, Brown L E, Aliferis C F. The max-min hill-climbing Bayesian network structure learning algorithm[J]. Machine learning, 2006, 65(1): 31-78.
[2]Tsamardinos I, Aliferis C F, Statnikov A. Time and sample efficient discovery of Markov blankets and direct causal relations[C]//Proceedings of the ninth ACM SIGKDD international conference on Knowledge discovery and data mining. 2003: 673-678.