零概率rb-libsvm - Zero probabilities in rb-libsvm

- 此内容更新于:2016-02-01
主题:

我用rb-libsvm预测使用它返回一个数组第一个元素标签,第二个是所有标签的概率。例如。每次的标签是不同的,但是概率总是零。我想知道因为数量太小,圆转换从c到ruby0.0。相关的c代码:我如何缓解呢?

原文:

I'm using rb-libsvm for prediction using

x.each_with_index do |e, i|
    predictions << model_w2v.predict_probability(e).to_i
end

Which returns an array where the first element is the label, and the second is the probabilities of all labels. E.g. [2.0, [0.0, 0.0, 0.0, 0.0, 0.0]]. The label is different each time, however the probabilities are always zeros. I wonder if it's because the numbers are too small and rounded to 0.0 when converting from c to ruby. Here's the relevant c code:

estimates = rb_ary_new();
for (i = 0; i < model->nr_class; i++)
  rb_ary_push(estimates, rx_from_double(c_estimates[i]));

How can I mitigate this?

解决方案:
我只需要添加
原文:

I just had to add

parameter.probability = 1