1

我的问题特定于 MatLab 中 BayesNetToolbox 的“learn_params()”函数。在用户手册中,“learn_params()”被声明为仅在完全观察输入数据的情况下才适合使用。我已经用部分观察到的数据集进行了尝试,其中我将未观察到的值表示为 NaN。

似乎“learn_params()”可以处理数据集中不出现的 NaN 和节点状态组合。当我应用狄利克雷先验来平滑 0 值时,我得到所有节点的“合理”MLE 分布。我已经复制了我执行此操作的脚本。

有人可以澄清我所做的事情是否有意义,或者我是否遗漏了什么,即“learn_params()”不能与部分观察到的数据一起使用的原因。

我测试的 MatLab 脚本在这里:

% Incomplete dataset (where NaN's are unobserved)
Age = [1,2,2,NaN,3,3,2,1,NaN,2,1,1,3,NaN,2,2,1,NaN,3,1]; 
TNMStage = [2,4,2,3,NaN,1,NaN,3,1,4,3,NaN,2,4,3,4,1,NaN,2,4];
Treatment = [2,3,3,NaN,2,NaN,4,4,3,3,NaN,2,NaN,NaN,4,2,NaN,3,NaN,4];
Survival = [1,2,1,2,2,1,1,1,1,2,2,1,2,2,1,2,1,2,2,1];
matrixdata = [Age;TNMStage;Treatment;Survival];
node_sizes =[3,4,4,2];

% Enter the variablesmap
keys = {'Age', 'TNM','Treatment', 'Survival'};
v= 1:1:length(keys);
VariablesMap = containers.Map(keys,v);

% create the dag and the bnet
N = length(node_sizes); % Instead of entering it manually
dag2 = zeros(N,N);
dag2(VariablesMap('Treatment'),VariablesMap('Survival')) = 1;
bnet21 = mk_bnet(dag2, node_sizes);
draw_graph(bnet21.dag);
dirichletweight=1;

% define the CPD priors you want to use
bnet23.CPD{VariablesMap('Age')} = tabular_CPD(bnet23, VariablesMap('Age'), 'prior_type', 'dirichlet','dirichlet_type', 'unif', 'dirichlet_weight', dirichletweight);
bnet23.CPD{VariablesMap('TNM')} = tabular_CPD(bnet23, VariablesMap('TNM'), 'prior_type', 'dirichlet','dirichlet_type', 'unif', 'dirichlet_weight', dirichletweight);
bnet23.CPD{VariablesMap('Treatment')} = tabular_CPD(bnet23, VariablesMap('Treatment'), 'prior_type', 'dirichlet','dirichlet_type', 'unif','dirichlet_weight', dirichletweight);
bnet23.CPD{VariablesMap('Survival')} = tabular_CPD(bnet23, VariablesMap('Survival'), 'prior_type', 'dirichlet','dirichlet_type', 'unif','dirichlet_weight', dirichletweight);

% Find MLEs from incomplete data with Dirichlet prior CPDs
bnet24 = learn_params(bnet23, matrixdata);

% Look at the new CPT values after parameter estimation has been carried out
CPT24 = cell(1,N);
for i=1:N
s=struct(bnet24.CPD{i}); % violate object privacy
CPT24{i}=s.CPT;
end
4

1 回答 1

1

根据我对 BNT 文档的理解,您需要进行一些更改:

  1. 缺失值应表示为空单元格而不是NaN值。
  2. learn_params_em函数是唯一支持缺失值的函数。

我之前的回答是不正确的,因为我记错了哪些 BNT 学习函数支持缺失值。

于 2012-07-14T00:37:58.050 回答