Class Classifier::Bayes
In: lib/classifier/bayes.rb
Parent: Object

Methods

Public Class methods

The class can be created with one or more categories, each of which will be initialized and given a training method. E.g.,

     b = Classifier::Bayes.new 'Interesting', 'Uninteresting', 'Spam'

Public Instance methods

Allows you to add categories to the classifier. For example:

    b.add_category "Not spam"

WARNING: Adding categories to a trained classifier will result in an undertrained category that will tend to match more criteria than the trained selective categories. In short, try to initialize your categories at initialization.

append_category(category)

Alias for add_category

Returns the scores in each category the provided text. E.g.,

   b.classifications "I hate bad words and you"
   =>  {"Uninteresting"=>-12.6997928013932, "Interesting"=>-18.4206807439524}

The largest of these scores (the one closest to 0) is the one picked out by classify

Returns the classification of the provided text, which is one of the categories given in the initializer. E.g.,

   b.classify "I hate bad words and you"
   =>  'Uninteresting'

Provides training and untraining methods for the categories specified in Bayes#new For example:

    b = Classifier::Bayes.new 'This', 'That', 'the_other'
    b.train_this "This text"
    b.train_that "That text"
    b.untrain_that "That text"
    b.train_the_other "The other text"

Provides a general training method for all categories specified in Bayes#new For example:

    b = Classifier::Bayes.new 'This', 'That', 'the_other'
    b.train :this, "This text"
    b.train "that", "That text"
    b.train "The other", "The other text"

Provides a untraining method for all categories specified in Bayes#new Be very careful with this method.

For example:

    b = Classifier::Bayes.new 'This', 'That', 'the_other'
    b.train :this, "This text"
    b.untrain :this, "This text"

[Validate]