• Stars
    star
    190
  • Rank 203,739 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 14 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Multi-variate Bayesian classification engine

bayes_motel

BayesMotel is a multi-variate Bayesian classification engine. There are two steps to Bayesian classification:

  1. Training You provide a set of variables along with the proper classification for that set.
  2. Runtime You provide a set of variables and ask for the proper classification according to the training in Step 1.

Commonly this is used for spam detection. You will provide a corpus of emails or other data along with a "Spam/NotSpam" classification. The library will determine which variables affect the classification and use that to judge future data.

Usage

Step one is to create a corpus that you can train with a set of previously classified documents:

corpse = BayesMotel::Corpus.new('tweets')
spam_tweets.each do |tweet|
  corpse.train(tweet, :spam)
end
good_tweets.each do |tweet|
  corpse.train(tweet, :ham)
end
corpse.cleanup

In this example, we have a set of spammy tweets and a set of known good tweets. We pass in each tweet to our train() method. Once we have completed training, we call cleanup which will run through the internal data structures and clean up any variables that are too 'unique' to make a difference in classification (for instance, an :id variable will be unique for each tweet and so will be removed in the cleanup since it does not repeat enough times).

Step two is to use the calculated corpus for the category scores or a classification for a given document:

corpse.scores(new_tweet)
=> { :spam => 12.4, :ham => 15.25 }
corpse.classify(new_tweet)
=> [:ham, 15.25]

Trivia

Bates Motel is the motel in Alfred Hitchcock's masterpiece Psycho. Corpus is Latin for "body" but also means 'a canonical set of documents'. I'm not crazy, I just like puns.

Author

Mike Perham, mperham AT gmail.com, @mperham, http://mikeperham.com

Copyright

Copyright (c) 2010 Mike Perham. See LICENSE for details.

More Repositories

1

sidekiq

Simple, efficient background processing for Ruby
Ruby
12,059
star
2

inspeqtor

Monitor your application infrastructure!
Go
1,657
star
3

connection_pool

Generic connection pooling for Ruby
Ruby
1,627
star
4

girl_friday

Have a task you want to get done but don't want to do it yourself? Give it to girl_friday!
Ruby
606
star
5

rack-fiber_pool

Rack middleware to execute each request in a Fiber
Ruby
244
star
6

evented

Your source for event-drivenness!
Ruby
172
star
7

phat

Asynchronous Rails!
Ruby
95
star
8

em_postgresql

ActiveRecord driver for Postgresql with EventMachine
Ruby
65
star
9

kuiq

Sidekiq desktop app
Ruby
55
star
10

inspeqtor-pro

Modern service monitoring, business edition.
Go
52
star
11

politics

Utilities and Algorithms for Distributed Processing.
Ruby
47
star
12

qanat

Fiber-based, highly concurrent MQ processor for Ruby
Ruby
39
star
13

chrono.js

Application metrics, webscale!
JavaScript
22
star
14

job_roundup

Benchmarking various background job engines
Ruby
17
star
15

bloaty_mcbloatface

"Oh my, you've put on some weight..."
Ruby
12
star
16

acting_lessons

Abusing Rubinius's Actors for fun and profit
Ruby
10
star
17

phony_baloney

Create fake servers for testing purposes
Ruby
10
star
18

gobox

How to use Golang's NaCl crypto API
Go
10
star
19

breakout

The classic Breakout game
Ruby
9
star
20

dotfiles

my dotfiles
Shell
7
star
21

blog

My blargh!
HTML
7
star
22

switch_redis

Ruby
7
star
23

discontent

The forum for terrible people
Ruby
7
star
24

sidekiq-websockets

Ruby
7
star
25

dotenv

Load contents of .env into child processes
Go
6
star
26

resque-client.go

Resque worker/client, written in Go
Go
6
star
27

contribsys.com

contribsys.com
CSS
5
star
28

edistuff

EDI parser and generation code
Java
5
star
29

queso

Query anything!
Ruby
5
star
30

gem_dir

Adds the 'gem dir' command to RubyGems to display the root directory of a given gem.
Ruby
4
star
31

tracknowledge

Race Tracks Galore!
Ruby
4
star
32

aoc2016

Advent of Code 2016
Ruby
4
star
33

right_aws

RightScale's right_aws 1.10.0 gem with fixes
Ruby
3
star
34

minesweeper

Minesweeper for MacRuby
3
star
35

docdb_shootout

Document-oriented database comparision
Ruby
3
star
36

news_flash

Show your users the latest news
Ruby
2
star
37

slice

My slice configuration
Ruby
1
star
38

perham.net

HTML
1
star