nb
yet another Naive Bayes library
Installation
Add this line to your application's Gemfile:
gem 'nb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install nb
Usage
bayes = NaiveBayes.new :love, :hate
bayes.train :love, 'I', 'love', 'you'
bayes.train :hate, 'I', 'hate', 'you'
bayes.classifications(*%w{ I love you }).should == [[:love, 0.5], [:hate, 0.25]]
bayes.classify(*%w{ I love you }).should == [:love, 0.5]
bayes.classify(*%w{ love }).should == [:love, 0.5]
ability to view top tokens
bayes.top_tokens_of_category(:spam)
+------------+------+--------------------+
|
Credits
Contributing
- Fork it ( https://github.com/forresty/nb/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request