如何使用WEKA API学习贝叶斯网络(结构+参数)?

| 有人知道使用WEKA API从数据中学习贝叶斯网络的“适当”过程吗?我在WEKA文档中找不到很好的说明。 根据文档以及每个功能“应”执行的操作,我认为这会起作用:
Instances ins = DataSource.read( filename );
ins.setClassIndex(0);

K2 learner = new K2();

MultiNomialBMAEstimator estimator = new MultiNomialBMAEstimator();
estimator.setUseK2Prior(true);

EditableBayesNet bn = new EditableBayesNet( ins );
bn.initStructure();

learner.buildStructure(bn, ins);
estimator.estimateCPTs(bn);
但事实并非如此。我已经尝试过这种方法和其他变体,但是在WEKA代码内的某处不断出现
ArrayIndexOutOfBoundsException
NullPointerException
,那么我还缺少什么?     
已邀请:
这个对我有用。我尝试使用以下数据集:
@relation test

@attribute x {0,1}
@attribute y {0,1,2}
@attribute z {0,1}

@data
0,1,0
1,0,1
1,1,1
1,2,1
0,0,0
让我说一下,当您的目标属性不是名义属性(例如数字)时,会出现例外情况。当所有属性均为标称值时,贝叶斯网络可以更好地工作。如果将target属性更改为数字,则会得到
NullPointerException
ArrayIndexOutOfBoundsException
。特别是,此异常被抛出:
EditableBayesNet bn = new EditableBayesNet(ins);
您应该首先离散化您的目标类。     

要回复问题请先登录注册