RAA - classifier

classifier / 1.2.0

Short description: Interface to Bayesian, LSI and other types of classification
Category: Library/Algorithm
Status: stable
Created: 2005-04-27 21:57:26 GMT
Last update: 2005-04-27 21:57:26 GMT
Owner: Lucas Carlson (Projects of this owner)
Homepage: http://classifier.rufy.com/
Download: http://rubyforge.org/projects/classifier
License: GPL
Dependency:
Requires: GSL/1.6 Only necessary for LSI: http://www.gnu.org/software/gsl
Requires: RubyGSL/1.6.2 Only necessary for LSI: http://rb-gsl.rubyforge.org/
Description:

Bayes

A Bayesian classifier by Lucas Carlson. Bayesian Classifiers are accurate, fast, and have modest memory requirements.

Usage

    require 'classifier'
    b = Classifier::Bayes.new 'Interesting', 'Uninteresting'
    b.train_interesting "here are some good words. I hope you love them"
    b.train_uninteresting "here are some bad words, I hate you"
    b.classify "I hate bad words and you" # returns 'Uninteresting'

    require 'madeleine'
    m = SnapshotMadeleine.new("bayes_data") {
        Classifier::Bayes.new 'Interesting', 'Uninteresting'
    }
    m.system.train_interesting "here are some good words. I hope you love them"
    m.system.train_uninteresting "here are some bad words, I hate you"
    m.take_snapshot
    m.system.classify "I love you" # returns 'Interesting'

Using Madeleine, your application can persist the learned data over time.

Bayesian Classification

LSI

An experimental Latent Semantic Indexer by David Fayram. Latent Semantic Indexing engines are not as fast or as small as Bayesian classifiers, but are more flexible, providing fast search and clustering detection as well as semantic analysis of the text that theoretically simulates human learning.

Usage

  require 'classifier'
  lsi = Classifier::LSI.new
  strings = [ ["This text deals with dogs. Dogs.", :dog],
              ["This text involves dogs too. Dogs! ", :dog],
              ["This text revolves around cats. Cats.", :cat],
              ["This text also involves cats. Cats!", :cat],
              ["This text involves birds. Birds.",:bird ]]
  strings.each {|x| lsi.add_item x.first, x.last}

  lsi.search("dog", 3)
  # returns => ["This text deals with dogs. Dogs.", "This text involves dogs too. Dogs! ",
  #             "This text also involves cats. Cats!"]

  lsi.find_related(strings[2], 2)
  # returns => ["This text revolves around cats. Cats.", "This text also involves cats. Cats!"]

  lsi.classify "This text is also about dogs!"
  # returns => :dog

Please see the Classifier::LSI documentation for more information. It is possible to index, search and classify with more than just simple strings.

Latent Semantic Indexing

Authors

Edit this project (for project owner)

back to RAA top