Weka:为什么getMargin返回全零? [英] Weka: why getMargin returns all zeros?

查看:127
本文介绍了Weka:为什么getMargin返回全零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Weka Java API.我在Instances对象(数据集)data上训练了Bayesnet.

I am using Weka Java API. I trained a Bayesnet on an Instances object (data set) data.

/**
 * Initialization
 */
Instances data = ...;
BayesNet bn = new EditableBayesNet(data);
SearchAlgorithm learner = new TAN();
SimpleEstimator estimator = new SimpleEstimator();
/**
 * Training
 */
bn.initStructure();
learner.buildStructure(bn, data);
estimator.estimateCPTs(bn);

getMargin返回节点的边际分布.理想情况下,假设节点A具有3个可能的值,并且其节点索引为0.然后,bn.getMargin(0)应该返回类似[0.3, 0.4, 0.3]的内容.

getMargin returns marginal distibution for a node. Ideally, assuming node A has 3 possible values, and its node index is 0. Then, bn.getMargin(0) should return something like [0.3, 0.4, 0.3].

但是,就我而言,当我使用以下代码打印所有节点的边际分布时.

However, in my case, when I print marginal distributions of all nodes using the following code.

for (int i = 0; i <bn.getNrOfNodes(); i++)
    System.out.println(Arrays.toString(bn.getMargin(i)));

返回

[0.0, 0.0, 0.0, ...]
[0.0, 0.0, 0.0, ...]
[0.0, 0.0, 0.0, ...]
...

有人曾经见过这种情况,或者可能给我一些提示为什么会发生这种情况?

Someone has seen this before or can possibly give me some hints why this happens?

我的数据是名义数据,大多数列具有许多类/值.

My data are nominal and most of the columns have many classes/values.

推荐答案

我认为我在GUI中看到了类似的内容.当MaxnrofParents = 2时,我可以在贝叶斯编辑器中看到边距,但是如果我使用更大的MaxnrofParents,则边距不会显示任何东西.

I think I saw something like this in the GUI. When I had MaxnrofParents = 2, I could see the margins in the Bayes Editor, but if I used MaxnrofParents of anything bigger, the margins didn't show anything.

这篇关于Weka:为什么getMargin返回全零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆