贝叶斯网络构造(python版)

本文介绍了贝叶斯网络,它是概率论与图论的结合,用于不确定性推理和数据分析。文章讨论了手工构造和机器学习方法构建贝叶斯网络,并重点讲述了后验概率推理问题。文中通过PATHFINDER专家系统的案例展示了贝叶斯网络在诊断推理中的应用,以及在违规报销预测项目中的应用框架。
摘要由CSDN通过智能技术生成

        贝叶斯网是一种帮助人们将概率统计应用于复杂领域,进行不确定性推理和数据分析的工具。他起源于人工智能领域的研究。贝叶斯网是一种系统地描述随机变量之间关系的语言。构造贝叶斯网的主要目的是进行概率推理,即计算一些事件发生的概率。贝叶斯网是概率论与图论相结合的产物,它一方面用图论的语言直观的揭示问题结构,另一方面又按照概率论的原则对问题结构加以利用,降低推理的计算复杂度。

        贝叶斯网络的构造主要有两种方式:第一种是通过咨询专家手工构造;第二种是通过数据分析获得(讨论利用机器学习的方法分析数据获得贝叶斯,即贝叶斯学习)。贝叶斯网络的构造主要包括两个方面:确定网络结构与评估条件概率。

        推理是通过计算回答查询的过程。贝叶斯网的推理问题有三大类:后验概率问题、最大后验假设问题以及最大可能解释问题。其中主要解决的推理问题是后验概率问题。后验概率问题指的是已知贝叶斯网络中某些变量的取值,计算另外一些变量的后验概率分布问题。主要有以下四种类型:第一种是从结果到原因的诊断推理;第二种是从原因到结果的预测推理;第三种是同一结果的不同原因之间的原因关联推理。

(以上知识概述一下什么是贝叶斯网、贝叶斯推理以及贝叶斯学习的概念,未涉及其中重要的算法,如:变量消元法、团树传播算法、随机抽样算法、EM算法、爬山算法等)

        以下来举一个具体实践的例子说明贝叶斯网的构造。

        为提高诊断水平,研发人员开发了一个叫做PATHFINDER的专家系统.这个贝叶斯网由开发人员和医疗专家一起手工建造的,确定变量及取值用了8h,确定网络拓扑结构用了35h,对总共14000个条件概率值的评估有用了40h,最终的到了一个由121个节点、195条边构成的网络。用PATHFINDER做推理问题,即给

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.)
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值