Bishop is a Bayesian classifier library for the Ruby programming language. It is a port of the Reverend classifier for Python written by Amir Bakhtiar as part of the Divmod project.
An example of using Bishop:
require 'bishop'
classifier = Bishop::Bayes.new { |probs,ignore| Bishop::robinson( probs, ignore ) }
classifier.train( "good", "this is an interesting message full of good cheer" )
classifier.train( "bad", "this is a bad message and we hate it" )
classifier.guess( "what do you think of a message like this?" )
The block passed to Bayes#new in this example shows how to replace the combiner algorithm. Bishop comes with Bishop::robinson and
Bishop::robinson_fisher algorithms. If no block is supplied the default #robinson algorithm is used.
Bishop supports storing the trained classifier to a YAML file using #save and #load. Alternatively #export and #load_data can be used to store/retrieve from other YAML sources (e.g. database).