• Stars
    star
    190
  • Rank 196,820 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 14 years ago
  • Updated about 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,659
star
3

connection_pool

Generic connection pooling for Ruby
Ruby
1,596
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
66
star
9

inspeqtor-pro

Modern service monitoring, business edition.
Go
52
star
10

kuiq

Sidekiq desktop app
Ruby
48
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

bloaty_mcbloatface

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

phony_baloney

Create fake servers for testing purposes
Ruby
10
star
16

acting_lessons

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

gobox

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

breakout

The classic Breakout game
Ruby
9
star
19

dotfiles

my dotfiles
Shell
7
star
20

switch_redis

Ruby
7
star
21

discontent

The forum for terrible people
Ruby
7
star
22

blog

My blargh!
HTML
7
star
23

sidekiq-websockets

Ruby
7
star
24

dotenv

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

resque-client.go

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

contribsys.com

contribsys.com
CSS
5
star
27

edistuff

EDI parser and generation code
Java
5
star
28

queso

Query anything!
Ruby
5
star
29

gem_dir

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

tracknowledge

Race Tracks Galore!
Ruby
4
star
31

aoc2016

Advent of Code 2016
Ruby
4
star
32

right_aws

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

minesweeper

Minesweeper for MacRuby
3
star
34

docdb_shootout

Document-oriented database comparision
Ruby
3
star
35

news_flash

Show your users the latest news
Ruby
2
star
36

slice

My slice configuration
Ruby
1
star
37

perham.net

HTML
1
star