问题描述
安装好工具箱后,将工具箱添加到路径后显示:
位置 2 处的索引超出数组边界(不能超出 2)。
出错 discrete_CPD/convert_to_table (line 14)
T = CPT(index{:});
出错 discrete_CPD/convert_to_pot (line 20)
T = convert_to_table(CPD, domain, evidence);
出错 jtree_inf_engine/enter_evidence (line 57)
pot{n} = convert_to_pot(bnet.CPD{e}, pot_type, fam(😃, evidence);
出错 Factorlearn (line 46)
[engine,loglik] = enter_evidence(engine,evidence);
猜测原因
按照提示,主要问题为超出索引范围,无非为父节点/子节点超出了取值范围,一般的工具箱都有默认取值方式。比如训练集、测试集中不能出现0等。另外一般的父节点和子节点按照一定的顺序如1、2、3、4…等,所以只需要把训练集中的数据换成1、2、3、4…等离散量、测试集中的数据换对应的数据即可
最终
最终按照自己的方法,顺利实现了想要的功能。