[求助]如何用matlab的BNT软件包对数据建立一个贝叶斯网络及条件概率表
我想用matlab的bnt工具包实现一个基于贝叶斯网络的试卷分析试验,但是程序总是调不出来,请高手们帮帮忙,给补充成一个可调试出来的程序吧。% 结构学习是K2算法,参数学习是最大后验
n=6;
ns=[3 3 2 2 3 3];
A=1; B=2; C=3; D=4; E=5; Class=6;
order=[4 5 6 3 2 1]; %指定节点次序
max_fan_in=2;
result_matrix=zeros(ns(Class),ns(Class));
%读入训练数据集
fn=’bdata_001.txt’;
load(fn);
fata_train1=bdata_001’;
[num_attrib num_cases]=size(data_train1);
data_train=zeros(num_attrib,num_cases);
%根据实例进行网络结构学习
dag_gbn=zeros(n,n);
dag_gbn=learn_struct-K2(data_train, ns, order, ’max_fan_in’, max_fan_in);
bnet2=mk_bnet(dag_gbn,ns);
%对生成的结构进行参数学习
priors=1;
seed=0;
rand(‘state’, seed);
for i=1:n
bnet2.CPD{i}=tabular_CPD(bnet2, i, ‘CPT’, ‘unif’, ‘prior_type’, ‘dirichlet_type’, ‘BDeu’,’dirichlet_weight’, priors);
end
bnet4=bayes_update_params(bnet2, data_train);
CPT3-cell(1,n);
for i=1:n
s=struct(bnet4,CPD{i});
CPT3{i}=s.CPT;
end
%画出图形
draw_graph(dag_gbn)
谢谢啦!!!!!
急需!!!!