Weka: why getMargin returns all zeros?

和自甴很熟 提交于 2019-12-25 00:23:13

问题


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 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)));

It returns

[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.


回答1:


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.



来源:https://stackoverflow.com/questions/53494595/weka-why-getmargin-returns-all-zeros

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!