naivebayes 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -3
- data/README.md +10 -8
- data/VERSION +1 -1
- data/demo.rb +23 -0
- data/doc/ChangeLog +5 -0
- data/lib/naivebayes/classifier.rb +1 -1
- data/naivebayes.gemspec +8 -10
- metadata +24 -29
- checksums.yaml +0 -7
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -19,10 +19,11 @@ The Bernoulli model.
|
|
19
19
|
+ http://nlp.stanford.edu/IR-book/html/htmledition/the-bernoulli-model-1.html
|
20
20
|
|
21
21
|
``` html
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
require 'naivebayes'
|
23
|
+
classifier = NaiveBayes::Classifier.new(:model => "berounoulli")
|
24
|
+
classifier.train("positive", {"aaa" => 0, "bbb" => 1})
|
25
|
+
classifier.train("negative", {"ccc" => 2, "ddd" => 3})
|
26
|
+
result = classifier.classify({"aaa" => 1, "bbb" => 1})
|
26
27
|
p result # => {"positive" => 0.8767123287671234,"negative" => 0.12328767123287669}
|
27
28
|
```
|
28
29
|
|
@@ -31,10 +32,11 @@ Relation to multinomial unigram language model.
|
|
31
32
|
+ http://nlp.stanford.edu/IR-book/html/htmledition/relation-to-multinomial-unigram-language-model-1.html
|
32
33
|
|
33
34
|
``` html
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
require 'naivebayes'
|
36
|
+
classifier = NaiveBayes::Classifier.new(:model => "multinomial")
|
37
|
+
classifier.train("positive", {"aaa" => 0, "bbb" => 1})
|
38
|
+
classifier.train("negative", {"ccc" => 2, "ddd" => 3})
|
39
|
+
result = classifier.classify({"aaa" => 1, "bbb" => 1})
|
38
40
|
p result # => {"positive" => 0.9411764705882353,"negative" => 0.05882352941176469}
|
39
41
|
```
|
40
42
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/demo.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require 'naivebayes'
|
5
|
+
|
6
|
+
puts "--- The Bernoulli model ---"
|
7
|
+
classifier = NaiveBayes::Classifier.new(:model => "berounoulli")
|
8
|
+
|
9
|
+
classifier.train("positive", {"aaa" => 0, "bbb" => 1})
|
10
|
+
classifier.train("negative", {"ccc" => 2, "ddd" => 3})
|
11
|
+
result = classifier.classify({"aaa" => 1, "bbb" => 1})
|
12
|
+
|
13
|
+
p result # => {"positive" => 0.8767123287671234,"negative" => 0.12328767123287669}
|
14
|
+
|
15
|
+
puts "--- Relation to multinomial unigram language model ---"
|
16
|
+
|
17
|
+
classifier = NaiveBayes::Classifier.new(:model => "multinomial")
|
18
|
+
|
19
|
+
classifier.train("positive", {"aaa" => 0, "bbb" => 1})
|
20
|
+
classifier.train("negative", {"ccc" => 2, "ddd" => 3})
|
21
|
+
result = classifier.classify({"aaa" => 1, "bbb" => 1})
|
22
|
+
|
23
|
+
p result # => {"positive" => 0.9411764705882353,"negative" => 0.05882352941176469}
|
data/doc/ChangeLog
CHANGED
data/naivebayes.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "naivebayes"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["id774"]
|
12
|
-
s.date = "2013-07-
|
12
|
+
s.date = "2013-07-09"
|
13
13
|
s.description = "Naive Bayes classifier"
|
14
14
|
s.email = "idnanashi@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
"README.md",
|
21
21
|
"Rakefile",
|
22
22
|
"VERSION",
|
23
|
+
"demo.rb",
|
23
24
|
"doc/AUTHORS",
|
24
25
|
"doc/COPYING",
|
25
26
|
"doc/COPYING.LESSER",
|
@@ -38,27 +39,24 @@ Gem::Specification.new do |s|
|
|
38
39
|
s.homepage = "http://github.com/id774/naivebayes"
|
39
40
|
s.licenses = ["GPL"]
|
40
41
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = "
|
42
|
+
s.rubygems_version = "1.8.24"
|
42
43
|
s.summary = "naivebayes"
|
43
44
|
|
44
45
|
if s.respond_to? :specification_version then
|
45
|
-
s.specification_version =
|
46
|
+
s.specification_version = 3
|
46
47
|
|
47
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
49
|
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
49
|
-
s.add_development_dependency(%q<bundler>, ["
|
50
|
-
s.add_development_dependency(%q<builder>, ["~> 3.1.0"])
|
50
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
51
51
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
52
52
|
else
|
53
53
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
54
|
-
s.add_dependency(%q<bundler>, ["
|
55
|
-
s.add_dependency(%q<builder>, ["~> 3.1.0"])
|
54
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
56
55
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
57
56
|
end
|
58
57
|
else
|
59
58
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
60
|
-
s.add_dependency(%q<bundler>, ["
|
61
|
-
s.add_dependency(%q<builder>, ["~> 3.1.0"])
|
59
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
62
60
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
63
61
|
end
|
64
62
|
end
|
metadata
CHANGED
@@ -1,69 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naivebayes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- id774
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: cucumber
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: bundler
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.3.5
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: builder
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.1.0
|
37
|
+
version: '0'
|
48
38
|
type: :development
|
49
39
|
prerelease: false
|
50
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
51
42
|
requirements:
|
52
|
-
- -
|
43
|
+
- - ! '>='
|
53
44
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
45
|
+
version: '0'
|
55
46
|
- !ruby/object:Gem::Dependency
|
56
47
|
name: jeweler
|
57
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
58
50
|
requirements:
|
59
|
-
- - '>='
|
51
|
+
- - ! '>='
|
60
52
|
- !ruby/object:Gem::Version
|
61
53
|
version: '0'
|
62
54
|
type: :development
|
63
55
|
prerelease: false
|
64
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
65
58
|
requirements:
|
66
|
-
- - '>='
|
59
|
+
- - ! '>='
|
67
60
|
- !ruby/object:Gem::Version
|
68
61
|
version: '0'
|
69
62
|
description: Naive Bayes classifier
|
@@ -77,6 +70,7 @@ files:
|
|
77
70
|
- README.md
|
78
71
|
- Rakefile
|
79
72
|
- VERSION
|
73
|
+
- demo.rb
|
80
74
|
- doc/AUTHORS
|
81
75
|
- doc/COPYING
|
82
76
|
- doc/COPYING.LESSER
|
@@ -94,25 +88,26 @@ files:
|
|
94
88
|
homepage: http://github.com/id774/naivebayes
|
95
89
|
licenses:
|
96
90
|
- GPL
|
97
|
-
metadata: {}
|
98
91
|
post_install_message:
|
99
92
|
rdoc_options: []
|
100
93
|
require_paths:
|
101
94
|
- lib
|
102
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
103
97
|
requirements:
|
104
|
-
- - '>='
|
98
|
+
- - ! '>='
|
105
99
|
- !ruby/object:Gem::Version
|
106
100
|
version: '0'
|
107
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
108
103
|
requirements:
|
109
|
-
- - '>='
|
104
|
+
- - ! '>='
|
110
105
|
- !ruby/object:Gem::Version
|
111
106
|
version: '0'
|
112
107
|
requirements: []
|
113
108
|
rubyforge_project:
|
114
|
-
rubygems_version:
|
109
|
+
rubygems_version: 1.8.24
|
115
110
|
signing_key:
|
116
|
-
specification_version:
|
111
|
+
specification_version: 3
|
117
112
|
summary: naivebayes
|
118
113
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 65b10d91e502fb42401e711db63ee55c3b39f144
|
4
|
-
data.tar.gz: b8d7bd3697bddda01a00be9ea6d51b67ac9f14af
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: bd2735e4b03c2c52157264c5bebd311f57cec81341db75d12fd926e5f6856fbb542387fe8f6eb4dffeca5999eb116f3fbb09024a4b56f93e1f376c467b2a0ad6
|
7
|
-
data.tar.gz: 487bf5d0b11de48bcd45d9e6b595657b42f503fc4893f354279312a5a096cf9ba8f64a64fdaa079b84fa174151ac6bed2306e72f9ecb54ac6d8c6e57dc84c9f1
|