simple_classifier 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README +7 -69
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/simple_classifier/bayes.rb +1 -1
- data/simple_classifier.gemspec +61 -0
- data/test/bayes/bayesian_test.rb +1 -1
- metadata +17 -4
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/README
CHANGED
@@ -1,88 +1,26 @@
|
|
1
|
-
==
|
1
|
+
== simple_classifier: Bayesian Classification without a lot of fuss
|
2
2
|
|
3
|
-
|
3
|
+
== Installation
|
4
4
|
|
5
|
-
|
5
|
+
* gem install simple_classifier
|
6
6
|
|
7
|
-
|
8
|
-
* gem install classifier
|
9
|
-
* svn co http://rufy.com/svn/classifier/trunk
|
10
|
-
|
11
|
-
== Dependencies
|
12
|
-
If you install Classifier from source, you'll need to install Martin Porter's stemmer algorithm with RubyGems as follows:
|
13
|
-
gem install stemmer
|
14
|
-
|
15
|
-
If you would like to speed up LSI classification by at least 10x, please install the following libraries:
|
16
|
-
GNU GSL:: http://www.gnu.org/software/gsl
|
17
|
-
rb-gsl:: http://rb-gsl.rubyforge.org
|
18
|
-
|
19
|
-
Notice that LSI will work without these libraries, but as soon as they are installed, Classifier will make use of them. No configuration changes are needed, we like to keep things ridiculously easy for you.
|
20
|
-
|
21
|
-
== Bayes
|
22
|
-
A Bayesian classifier by Lucas Carlson. Bayesian Classifiers are accurate, fast, and have modest memory requirements.
|
7
|
+
simple_classifier depends on Martin Porter's stemmer gem, which should be installed when you run the command above.
|
23
8
|
|
24
9
|
=== Usage
|
25
|
-
require '
|
10
|
+
require 'simple_classifier'
|
26
11
|
b = Classifier::Bayes.new 'Interesting', 'Uninteresting'
|
27
12
|
b.train_interesting "here are some good words. I hope you love them"
|
28
13
|
b.train_uninteresting "here are some bad words, I hate you"
|
29
14
|
b.classify "I hate bad words and you" # returns 'Uninteresting'
|
30
15
|
|
31
|
-
|
32
|
-
m = SnapshotMadeleine.new("bayes_data") {
|
33
|
-
Classifier::Bayes.new 'Interesting', 'Uninteresting'
|
34
|
-
}
|
35
|
-
m.system.train_interesting "here are some good words. I hope you love them"
|
36
|
-
m.system.train_uninteresting "here are some bad words, I hate you"
|
37
|
-
m.take_snapshot
|
38
|
-
m.system.classify "I love you" # returns 'Interesting'
|
39
|
-
|
40
|
-
Using Madeleine, your application can persist the learned data over time.
|
41
|
-
|
42
|
-
=== Bayesian Classification
|
16
|
+
=== More info on Bayesian Classification
|
43
17
|
|
44
18
|
* http://www.process.com/precisemail/bayesian_filtering.htm
|
45
19
|
* http://en.wikipedia.org/wiki/Bayesian_filtering
|
46
20
|
* http://www.paulgraham.com/spam.html
|
47
21
|
|
48
|
-
== LSI
|
49
|
-
A Latent Semantic Indexer by David Fayram. Latent Semantic Indexing engines
|
50
|
-
are not as fast or as small as Bayesian classifiers, but are more flexible, providing
|
51
|
-
fast search and clustering detection as well as semantic analysis of the text that
|
52
|
-
theoretically simulates human learning.
|
53
|
-
|
54
|
-
=== Usage
|
55
|
-
require 'classifier'
|
56
|
-
lsi = Classifier::LSI.new
|
57
|
-
strings = [ ["This text deals with dogs. Dogs.", :dog],
|
58
|
-
["This text involves dogs too. Dogs! ", :dog],
|
59
|
-
["This text revolves around cats. Cats.", :cat],
|
60
|
-
["This text also involves cats. Cats!", :cat],
|
61
|
-
["This text involves birds. Birds.",:bird ]]
|
62
|
-
strings.each {|x| lsi.add_item x.first, x.last}
|
63
|
-
|
64
|
-
lsi.search("dog", 3)
|
65
|
-
# returns => ["This text deals with dogs. Dogs.", "This text involves dogs too. Dogs! ",
|
66
|
-
# "This text also involves cats. Cats!"]
|
67
|
-
|
68
|
-
lsi.find_related(strings[2], 2)
|
69
|
-
# returns => ["This text revolves around cats. Cats.", "This text also involves cats. Cats!"]
|
70
|
-
|
71
|
-
lsi.classify "This text is also about dogs!"
|
72
|
-
# returns => :dog
|
73
|
-
|
74
|
-
Please see the Classifier::LSI documentation for more information. It is possible to index, search and classify
|
75
|
-
with more than just simple strings.
|
76
|
-
|
77
|
-
=== Latent Semantic Indexing
|
78
|
-
* http://www.c2.com/cgi/wiki?LatentSemanticIndexing
|
79
|
-
* http://www.chadfowler.com/index.cgi/Computing/LatentSemanticIndexing.rdoc
|
80
|
-
* http://en.wikipedia.org/wiki/Latent_semantic_analysis
|
81
|
-
|
82
22
|
== Authors
|
23
|
+
* Ben Orenstein (mailto:ben.orenstein@gmail.com)
|
83
24
|
* Lucas Carlson (mailto:lucas@rufy.com)
|
84
|
-
* David Fayram II (mailto:dfayram@gmail.com)
|
85
|
-
* Cameron McBride (mailto:cameron.mcbride@gmail.com)
|
86
25
|
|
87
26
|
This library is released under the terms of the GNU LGPL. See LICENSE for more details.
|
88
|
-
|
data/Rakefile
CHANGED
@@ -44,6 +44,7 @@ begin
|
|
44
44
|
gemspec.email = "ben.orenstein@gmail.com"
|
45
45
|
gemspec.homepage = "http://github.com/r00k/simple_classifier"
|
46
46
|
gemspec.authors = ["Ben Orenstein", "Lucas Carlson", "David Fayram II"]
|
47
|
+
gemspec.add_dependency 'stemmer'
|
47
48
|
end
|
48
49
|
Jeweler::GemcutterTasks.new
|
49
50
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{simple_classifier}
|
8
|
+
s.version = "2.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ben Orenstein", "Lucas Carlson", "David Fayram II"]
|
12
|
+
s.date = %q{2010-02-26}
|
13
|
+
s.email = %q{ben.orenstein@gmail.com}
|
14
|
+
s.executables = ["bayes.rb", "summarize.rb"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"bin/bayes.rb",
|
26
|
+
"bin/summarize.rb",
|
27
|
+
"install.rb",
|
28
|
+
"lib/simple_classifier.rb",
|
29
|
+
"lib/simple_classifier/bayes.rb",
|
30
|
+
"lib/simple_classifier/extensions/string.rb",
|
31
|
+
"lib/simple_classifier/extensions/word_hash.rb",
|
32
|
+
"simple_classifier.gemspec",
|
33
|
+
"test/bayes/bayesian_test.rb",
|
34
|
+
"test/extensions/word_hash_test.rb",
|
35
|
+
"test/test_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/r00k/simple_classifier}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.6}
|
41
|
+
s.summary = %q{A simple bayesian classifier}
|
42
|
+
s.test_files = [
|
43
|
+
"test/test_helper.rb",
|
44
|
+
"test/bayes/bayesian_test.rb",
|
45
|
+
"test/extensions/word_hash_test.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<stemmer>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<stemmer>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<stemmer>, [">= 0"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
data/test/bayes/bayesian_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
class BayesianTest < Test::Unit::TestCase
|
3
3
|
def setup
|
4
|
-
@classifier =
|
4
|
+
@classifier = SimpleClassifier::Bayes.new 'Interesting', 'Uninteresting'
|
5
5
|
end
|
6
6
|
|
7
7
|
def test_good_training
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 1
|
9
|
+
version: 2.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben Orenstein
|
@@ -18,8 +18,19 @@ cert_chain: []
|
|
18
18
|
|
19
19
|
date: 2010-02-26 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: stemmer
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
23
34
|
description:
|
24
35
|
email: ben.orenstein@gmail.com
|
25
36
|
executables:
|
@@ -31,6 +42,7 @@ extra_rdoc_files:
|
|
31
42
|
- LICENSE
|
32
43
|
- README
|
33
44
|
files:
|
45
|
+
- .gitignore
|
34
46
|
- LICENSE
|
35
47
|
- README
|
36
48
|
- Rakefile
|
@@ -42,6 +54,7 @@ files:
|
|
42
54
|
- lib/simple_classifier/bayes.rb
|
43
55
|
- lib/simple_classifier/extensions/string.rb
|
44
56
|
- lib/simple_classifier/extensions/word_hash.rb
|
57
|
+
- simple_classifier.gemspec
|
45
58
|
- test/bayes/bayesian_test.rb
|
46
59
|
- test/extensions/word_hash_test.rb
|
47
60
|
- test/test_helper.rb
|