2

We are trying to do naive bayes classification in Ruby.

Currently we are using http://ai4r.rubyforge.org/

We couldn't get it working for float values and have about 20% points lower accuracy with string values. With float/integers we get a [] no implicit conversion from nil to integer. We convert floats with to_s.

Is there a way to get float values working? If not what are alternative gems to ai4r for ruby or alternative algorithms to naive bayes?

merv
  • 67,214
  • 13
  • 180
  • 245

2 Answers2

2

The "...implicit conversion..." error is coming from within the Ruby interpreter in a context where an Integer is required but a nil is found.

It's a bit hard to get this error but one way to see it is:

Array.new(nil)

...so that's probably what is happening in your case.

And in fact, gems/ai4r-1.9/lib/ai4r/classifiers/naive_bayes.rb does actually use the rather rare construct of Array.new(...).

The value passed to Array.new() depends on what Ai4r::Data::DataSet returns from #build_domains.

I know this doesn't solve your problem but perhaps it will help you proceed further with your analysis.

DigitalRoss
  • 143,651
  • 25
  • 248
  • 329
1

I know this question is an older one, but I wanted to point out a more robust Ruby gem for Naive Bayes classification:

https://github.com/oasic/nbayes

jman
  • 392
  • 2
  • 7