使用R语言的BNLearn包实现贝叶斯网络使用R语言的BNLearn包实现贝叶斯网络.pdf
文本预览下载声明
使用 R 语言的 BNLearn 包实现贝叶斯网络 (1 )
标签:生活 2013-08-01 22:26 星期四
1. 加载程序包导入数据
libr ry (bnle rn) #CRAN 中有,可以直接用 inst ll.p ck ges( “bnle rn”)安装或者去网
上下载后复制到 libr ry 文件夹下即可。
libr ry (Rgr phviz) #用于绘图。这个包 CRAN 中没有,需要到
/p ck ges/rele se/BiocViews.html#___Softw re 去下载。
d t (le rning.test) #导入数据,数据框中的变量必须全部为因子型 (离散)或数值型
(连续)。
le r.test =re d.csv (***.csv, colCl sses =f ctor) #也可以直接从 csv 文件直接
导入数据。需要注意的是如果数据中含有 0-1 之类的布尔型,或者 1-3 之类的等级数据,需
要强行指定其为因子型,不然许多 BN 函数会报错。因为 re d 函数只会自动的将字符型转换
成因子型,其他的不会 自动转换。
该包包含贝叶斯网络的结构学习、参数学习和推理三个方面的功能,其中结构学习包含基于约
束的算法、基于得分的算法和混合算法,参数学习包括最大似然估计和贝叶斯估计两种方法。
此外还有引导 (bootstr p),交叉验证 (cross-v lid tion)和随机模拟 (stoch stic
simul tion)等功能,附加的绘图功能需要调用前述的Rgr phviz nd l ttice 包。
B yesi n network structure le rning (vi constr int-b sed, score-b sed nd hybrid
lgorithms), p r meter le rning (vi ML nd B yesi n estim tors) nd inference.
This p ck ge implements some lgorithms for le rning the structure of B yesi n networks.
Constr int-b sed lgorithms, lso known s condition l independence le rners, re ll
optimized deriv tives of the Inductive C us tion lgorithm (Verm nd Pe rl, 1991).
These lgorithms use condition l independence tests to detect the M rkov bl nkets
of the v ri bles, which in turn re used to compute the structure of the B yesi n
network.
Score-b sed le rning lgorithms re gener l purpose heuristic optimiz tion lgorithms
which r nk network structures with respect to goodness-of-fit score.
Hybrid lgorithms combine spects of both constr int-b sed nd score-b sed lgorithms,
s they use condition l independence tests (usu lly to reduce the se rch sp ce) nd
network scores (to find the optim l network in the reduced sp ce) t the s me time.
Sever l functions for p r meter estim tion, p r metric inference, bootstr p,
cross-v lid tion nd stoch stic simul tion re
显示全部