Bayesian Networks ——Stanford CS228

Bayesian Networks

  • 学习一个有效广泛的技术用来参数化概率分布仅仅用少量的参数。
  • 通过有向无环图(DAGs)来描述因果模型。
  • 研究模型假设和DAG结构之间的关联;不仅模型假设要很清楚,而且应该设计更有效的推断算法。
    在下一节,将研究无向图,也被称之为Markov random fields。

基于BN的概率模型

有向图模型是使用简洁的参数的概率分布家族。

链式法则:
这里写图片描述
链式法则一般依赖的较多的其他变量。

所以一个简洁的贝叶斯网络既是一个分布仅仅依赖几个数量的祖先变量$x_{Ai}$:这里写图片描述

当变量是离散的,假如每个变量能取d个值,一个共k个祖先,所以N个变量有$O(nd^{k+1})$参数。

图表示

分布被表示有向无环图,图的顶点代表变量$x_{i}$,边代表依赖关系,记$x_{A_{i}}$为$x_{i}$的祖先。举个例子:g是学生的成绩,d是成绩的困难程度,i是学生的智商,s是SAT分数,l取决于教课老师的水平,除了g之外都是二值变量,g有三个变量值。那么联合分布为
这里写图片描述

这里写图片描述

这个图比较明显的显示数据的产生过程。

形式化定义-formal definition

贝叶斯网络是有向无环G=(V,E)

  • 随机变量x_{i}为图的顶点
  • 对于每个顶点条件概率分布(CPD),依赖于他们的父节点。

所以贝叶斯网络就是用来定义一个概率分布。

贝叶斯网络的依赖性(The dependencies of a Bayes net)

我们已经知道贝叶斯网络是用来表示一个分布的,用形式模型来表示非依赖。那种贝叶斯网络结构能够表达出来非独立性?记I(p)表示的事联合分布的变量是否独立。即如果p(x,y)=p(x)p(y),然后我们有$x \bot y\in I(p)$

基于有向图独立性描述(independencies decribed by directed graphs)

三种结构描述图的独立性。

  • 公共父节点。 结构一A<-B->C, 如果B是被观察节点,$(A \bot C)|B$;如果B不是观察节点,则$Anot \bot B$,因为A和C是和B有关联的。
  • 层级状。结构二A->B->C,如果B是被观察节点,$(A \bot C)|B$;同样果B不是观察节点,则$Anot \bot B$,因为A和C是和B有关联的。
  • V型。结构A->C<-B.如果C不是被观察节点,$(A \bot B)$;如果C是观察节点,则$Anot \bot B|C$,因为A和B是和C有关联的。

我们接下来将扩展这三种结构通过递归的。

当变量O被观测,如果集合Q,W,O是没有链接的通过active path,则说明QW是d分的(d-separated). active path,满足下面一个条件:

  • x<-Y<-Z,Y不是被观测变量,$Y\notin O$;
  • x->Y->Z,Y不是被观测变量,$Y\notin O$;
  • x<-Y->Z,Y不是被观测变量,$Y\notin O$;
  • x->U<-Z,Y是所有节点的子孙,并且是观测变量;
    这里写图片描述
    d-separation 用处在于描述网络的依赖。$I(G)=X\bot Y|Z:X,Y$是可d-分在Z条件下}
定理:如果p是G的因子,然后$I(G)\subseteq I(p)$,在这种情况下,我们说G是I-map对于p.

换句话说,就是所有的独立性编码在G上:如果变量是d-可分,那么这些是独立的。但是,一个分布能通过G因式分解,但是独立性可能存在不能完全被G捕捉。举个例子,p(x,y)=p(x)p(y),然后这个分布也能表示为y->x。由于我们常常表示p(x,y)=p(x|y)p(y),CPD p(x|y)。所以我们重构一个图来搭配去除没有必要的边。

有向图表示的力量(the representational power of directed graphs)

还是哪个问题有向图能表示所有独立关系?在大多关系下,给出分布p,是否能构成有向图I(G)=I(p)?

首先,很容易构建一个$I(G)\subseteqI(p)$.一个全链接的DAG G是I-Map,因为I(G)=$\emptyset$.

最重要的是我们可以发现一个最小的I-map G。很容易达到,先构建一个全链接的G,然后去除一些边,直到G不是一个I-map. (优化方法)。然而,我们真正感兴趣的是p是否存在一个完美的G能够达到I(p)=I(G).

如果I(G1)=I(G2),则G1和G2是I-equivalent。

相同的骨架的意思是将箭头去掉,是否能得到相同的无向图。层级明显是骨架相同。a,b,c是编码相同独立。但是c,d骨架不同。
这里写图片描述
定理:如果G和G1有相同的骨架和相同的V型结构,然后有I(G)=I(G1).

用python写的一段贝叶斯网络的程序 This file describes a Bayes Net Toolkit that we will refer to now as BNT. This version is 0.1. Let's consider this code an "alpha" version that contains some useful functionality, but is not complete, and is not a ready-to-use "application". The purpose of the toolkit is to facilitate creating experimental Bayes nets that analyze sequences of events. The toolkit provides code to help with the following: (a) creating Bayes nets. There are three classes of nodes defined, and to construct a Bayes net, you can write code that calls the constructors of these classes, and then you can create links among them. (b) displaying Bayes nets. There is code to create new windows and to draw Bayes nets in them. This includes drawing the nodes, the arcs, the labels, and various properties of nodes. (c) propagating a-posteriori probabilities. When one node's probability changes, the posterior probabilities of nodes downstream from it may need to change, too, depending on firing thresholds, etc. There is code in the toolkit to support that. (d) simulating events ("playing" event sequences) and having the Bayes net respond to them. This functionality is split over several files. Here are the files and the functionality that they represent. BayesNetNode.py: class definition for the basic node in a Bayes net. BayesUpdating.py: computing the a-posteriori probability of a node given the probabilities of its parents. InputNode.py: class definition for "input nodes". InputNode is a subclass of BayesNetNode. Input nodes have special features that allow them to recognize evidence items (using regular-expression pattern matching of the string descriptions of events). OutputNode.py: class definition for "output nodes". OutputBode is a subclass of BayesNetNode. An output node can have a list of actions to be performed when the node's posterior probability exceeds a threshold ReadWriteSigmaFiles.py: Functionality for loading and saving Bayes nets in an XML format. SampleNets.py: Some code that constructs a sample Bayes net. This is called when SIGMAEditor.py is started up. SIGMAEditor.py: A main program that can be turned into an experimental application by adding menus, more code, etc. It has some facilities already for loading event sequence files and playing them. sample-event-file.txt: A sequence of events that exemplifies the format for these events. gma-mona.igm: A sample Bayes net in the form of an XML file. The SIGMAEditor program can read this type of file. Here are some limitations of the toolkit as of 23 February 2009: 1. Users cannot yet edit Bayes nets directly in the SIGMAEditor. Code has to be written to create new Bayes nets, at this time. 2. If you select the File menu's option to load a new Bayes net file, you get a fixed example: gma-mona.igm. This should be changed in the future to bring up a file dialog box so that the user can select the file. 3. When you "run" an event sequence in the SIGMAEditor, the program will present each event to each input node and find out if the input node's filter matches the evidence. If it does match, that fact is printed to standard output, but nothing else is done. What should then happen is that the node's probability is updated according to its response method, and if the new probability exceeds the node's threshold, then its successor ("children") get their probabilities updated, too. 4. No animation of the Bayes net is performed when an event sequence is run. Ideally, the diagram would be updated dynamically to show the activity, especially when posterior probabilities of nodes change and thresholds are exceeded. To use the BNT, do three kinds of development: A. create your own Bayes net whose input nodes correspond to pieces of evidence that might be presented and that might be relevant to drawing inferences about what's going on in the situation or process that you are analyzing. You do this by writing Python code that calls constructors etc. See the example in SampleNets.py. B. create a sample event stream that represents a plausible sequence of events that your system should be able to analyze. Put this in a file in the same format as used in sample-event-sequence.txt. C. modify the code of BNT or add new modules as necessary to obtain the functionality you want in your system. This could include code to perform actions whenever an output node's threshold is exceeded. It could include code to generate events (rather than read them from a file). And it could include code to describe more clearly what is going on whenever a node's probability is updated (e.g., what the significance of the update is -- more certainty about something, an indication that the weight of evidence is becoming strong, etc.)
贝叶斯网络(Bayesian Networks)和决策图(Decision Graphs)是概率图模型的两种重要表示方法。 贝叶斯网络是一种有向无环图(DAG),用于表示变量之间的概率依赖关系。它由节点和边组成,节点代表变量,边代表变量之间的依赖关系。节点上的条件概率表(CPT)表示了每个变量在给定其父节点的情况下的条件概率分布。贝叶斯网络可以用于推理、预测和决策,能够有效地处理不确定性和复杂的因果关系。通过观察变量的取值,可以通过网络推理得到其他变量的后验概率分布。 决策图是一种扩展了贝叶斯网络的概率图模型,用于表示决策问题中的不确定性。它在贝叶斯网络的基础上增加了决策节点和价值节点。决策节点代表决策者可选择的行动,价值节点代表决策结果的效用或代价。决策图通过考虑不同决策和可能的事件后续产生的不确定性,帮助决策者进行最佳决策的评估。通过采用不同的策略,可以计算出每个决策的期望效用,并选择具有最高期望效用的决策。 贝叶斯网络和决策图是概率模型的重要工具,广泛应用于人工智能、机器学习和决策分析等领域。它们能够帮助我们理解和描述变量之间的关系,优化决策过程,并在不确定性环境中进行推理和预测。同时,对于复杂的问题,可以通过构建和学习这些概率图模型,得到更好的解释和决策支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水煮城府、器

谢谢你的欣赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值