Skip to content

Instantly share code, notes, and snippets.

@joshcutler
Created November 14, 2011 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshcutler/1363069 to your computer and use it in GitHub Desktop.
Save joshcutler/1363069 to your computer and use it in GitHub Desktop.
Use case of Classyfier
require 'classyfier'
@classyfier = Classyfier::NaiveBayes::NaiveBayesClassifier.new
@classyfier.train({:subject => 'Must read!', :text => 'Get Viagra cheap!'}, :spam)
@classyfier.train({:subject => 'Gotta see this', :text => 'Viagra. You can get it at cut rates'}, :spam)
@classyfier.train({:subject => 'Call me tomorrow', :text => 'We need to talk about scheduling. Call me.'}, :not_spam)
@classyfier.train({:subject => 'That was hilarious', :text => 'Just saw that link you sent me'}, :not_spam)
@classyfier.train({:subject => 'dinner at 7', :text => 'I got us a reservation tomorrow at 7'}, :not_spam)
@scores = @classyfier.classify({:subject => 'See it to believe it', :text => 'Best rates you\'ll see'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment