nb_class 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +1 -0
- data/lib/nb_class/classifier.rb +140 -0
- data/lib/nb_class/error/category_name_already_exists.rb +7 -0
- data/lib/nb_class/error/invalid_category_name.rb +6 -0
- data/lib/nb_class/phrase_array.rb +24 -0
- data/lib/nb_class/utils.rb +10 -0
- data/lib/nb_class/version.rb +3 -0
- data/lib/nb_class.rb +4 -0
- data/nb_class.gemspec +25 -0
- data/spec/nb_class/classifier_spec.rb +108 -0
- data/spec/nb_class/phrase_array_spec.rb +47 -0
- data/spec/nb_class/utils_spec.rb +13 -0
- data/spec/spec_helper.rb +3 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f32812e7a50cf5358cdb78a9b64842c0f7070420
|
4
|
+
data.tar.gz: 3bec851e5fb7b279a4ca67fdc912c9b338d8ce05
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ee190c6e18d28634f7f5e16501af078f941bcdb8d868adb642dd6408d79743db495ba30ce4375ddcaa6e344135fb65fb226860e2fb97ca12682c00eeee6c8f6
|
7
|
+
data.tar.gz: 93c4819682deada7c6e8953188ec10d29906b9e932f0a12b484320a859d4ae4a8e8543194e706cd1e6a98f8272549a0344b3212a2a6c1e252f29440405eb4c7a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Humberto C Marchezi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# NBClass
|
2
|
+
|
3
|
+
This gem provides a naive bayes classifier for models with N features.
|
4
|
+
Simply put given examples of pre-defined categories the classifier learns how
|
5
|
+
to classify new unknown examples.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Classifier can be used in three steps:
|
10
|
+
|
11
|
+
1. Provide category names and its respective training set
|
12
|
+
|
13
|
+
2. Train classifier with provided categories
|
14
|
+
|
15
|
+
3. Classify models
|
16
|
+
|
17
|
+
For instance the example below shows how to classify words in categories test_a and test_b.
|
18
|
+
Taking in consideration the number of occurrences of each word in both categories besides
|
19
|
+
the frequency of the category the classifier returns the most probable category for the
|
20
|
+
given collection of features.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require 'nb_class/classifier'
|
24
|
+
|
25
|
+
# 1 - Providing examples
|
26
|
+
classifier = NBClass::Classifier.new
|
27
|
+
classifier.not_spam << "Hi Joe, how are you?"
|
28
|
+
classifier.spam << "Buy products you don't need"
|
29
|
+
|
30
|
+
# 2 - Train classifier
|
31
|
+
classifier.train
|
32
|
+
|
33
|
+
# 3 - Classify new examples
|
34
|
+
classifier.classify("Hi James, are you going?") # => not_spam
|
35
|
+
classifier.classify("Buy not needed product") # => spam
|
36
|
+
```
|
37
|
+
|
38
|
+
## Planed Future Features
|
39
|
+
|
40
|
+
1. Load category examples from external files to reduce code size
|
41
|
+
2. Load pre-trained data from file to decrease classifier initialization time
|
42
|
+
3. Optimize algorithms to use pre-calculated values
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'nb_class/error/category_name_already_exists'
|
2
|
+
require 'nb_class/error/invalid_category_name'
|
3
|
+
require 'nb_class/phrase_array'
|
4
|
+
require 'nb_class/utils'
|
5
|
+
|
6
|
+
module NBClass
|
7
|
+
class Classifier
|
8
|
+
SMALL_PROBABILITY = 0.000001
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@category_examples = {}
|
12
|
+
@occurrences = {}
|
13
|
+
@global_occurrences = {}
|
14
|
+
@probabilities = {}
|
15
|
+
@global_probabilities = {}
|
16
|
+
@category_occurrences = {}
|
17
|
+
@total_elements = 0
|
18
|
+
@total_phrases = 0;
|
19
|
+
end
|
20
|
+
|
21
|
+
def categories
|
22
|
+
@category_examples.keys
|
23
|
+
end
|
24
|
+
|
25
|
+
def train
|
26
|
+
@category_examples.keys.each do |category|
|
27
|
+
@category_examples[category].each do |phrase|
|
28
|
+
phrase.each do |word|
|
29
|
+
count_element_occurrence_in_category(category,word)
|
30
|
+
count_element_occurrence_in_global(word)
|
31
|
+
@total_elements += 1
|
32
|
+
end
|
33
|
+
count_category_occurrence(category)
|
34
|
+
@total_phrases += 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def classify(elements)
|
40
|
+
elements = Utils.break_phrase_in_word_array(elements)
|
41
|
+
max_category = nil
|
42
|
+
max_probability = 0.0
|
43
|
+
@occurrences.keys.each do |key|
|
44
|
+
probability = category_probability_given_elements(category: key,elements: elements)
|
45
|
+
if probability > max_probability
|
46
|
+
max_probability = probability
|
47
|
+
max_category = key
|
48
|
+
end
|
49
|
+
end
|
50
|
+
max_category
|
51
|
+
end
|
52
|
+
|
53
|
+
def element_occurrence(params)
|
54
|
+
category = params[:category]
|
55
|
+
element = params[:element]
|
56
|
+
if category
|
57
|
+
@occurrences[category][element]
|
58
|
+
else
|
59
|
+
@global_occurrences[element]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def element_probability_given_category(params)
|
64
|
+
category = params[:category]
|
65
|
+
element = params[:element]
|
66
|
+
element_occurrence_in_category = @occurrences[category][element]
|
67
|
+
total_elements_in_category = @occurrences[category].map{ |item| item[1] }.inject{ |sum, item| sum + item }
|
68
|
+
unless element_occurrence_in_category.nil?
|
69
|
+
element_occurrence_in_category.to_f / total_elements_in_category.to_f
|
70
|
+
else
|
71
|
+
SMALL_PROBABILITY
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def element_probability(element)
|
76
|
+
element_occurrence = @global_occurrences[element]
|
77
|
+
unless element_occurrence.nil?
|
78
|
+
element_occurrence.to_f / @total_elements
|
79
|
+
else
|
80
|
+
SMALL_PROBABILITY
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def category_probability(category)
|
85
|
+
@category_occurrences[category].to_f / @total_phrases.to_f
|
86
|
+
end
|
87
|
+
|
88
|
+
def category_probability_given_elements(params)
|
89
|
+
category = params[:category]
|
90
|
+
elements = params[:elements]
|
91
|
+
probability = 1.0
|
92
|
+
elements.each do |element|
|
93
|
+
element_probability_given_category = element_probability_given_category(category: category, element: element)
|
94
|
+
element_global_probability = element_probability(element)
|
95
|
+
element_probability = element_probability_given_category / element_global_probability
|
96
|
+
probability *= element_probability
|
97
|
+
end
|
98
|
+
category_probability = category_probability(category)
|
99
|
+
probability *= category_probability
|
100
|
+
probability
|
101
|
+
end
|
102
|
+
|
103
|
+
def method_missing(name, *args, &block)
|
104
|
+
@category_examples[name] = PhraseArray.new
|
105
|
+
define_singleton_method name do
|
106
|
+
@category_examples[name]
|
107
|
+
end
|
108
|
+
public_send(name)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def count_element_occurrence_in_category(category, element)
|
114
|
+
unless @occurrences.has_key?(category)
|
115
|
+
@occurrences[category] = {}
|
116
|
+
end
|
117
|
+
if !@occurrences[category].has_key?(element)
|
118
|
+
@occurrences[category][element] = 1
|
119
|
+
else
|
120
|
+
@occurrences[category][element] += 1
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def count_element_occurrence_in_global(element)
|
125
|
+
unless @global_occurrences.has_key?(element)
|
126
|
+
@global_occurrences[element] = 1
|
127
|
+
else
|
128
|
+
@global_occurrences[element] += 1
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def count_category_occurrence(category)
|
133
|
+
if @category_occurrences[category].nil?
|
134
|
+
@category_occurrences[category] = 1
|
135
|
+
else
|
136
|
+
@category_occurrences[category] += 1
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'nb_class/utils'
|
2
|
+
|
3
|
+
module NBClass
|
4
|
+
class PhraseArray
|
5
|
+
def initialize
|
6
|
+
@phrase_array = []
|
7
|
+
end
|
8
|
+
def <<(phrase)
|
9
|
+
@phrase_array << Utils.break_phrase_in_word_array(phrase)
|
10
|
+
end
|
11
|
+
def size
|
12
|
+
@phrase_array.size
|
13
|
+
end
|
14
|
+
def [](index)
|
15
|
+
@phrase_array[index]
|
16
|
+
end
|
17
|
+
def each(&block)
|
18
|
+
@phrase_array.each(&block)
|
19
|
+
end
|
20
|
+
def to_s
|
21
|
+
@phrase_array.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/nb_class.rb
ADDED
data/nb_class.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nb_class/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nb_class"
|
8
|
+
spec.version = NBClass::VERSION
|
9
|
+
spec.authors = ["Humberto Marchezi"]
|
10
|
+
spec.email = ["hcmarchezi@gmail.com"]
|
11
|
+
spec.description = "Machine learning text classifier"
|
12
|
+
spec.summary = "This gem offers a simplified interface to allow a text classifier to be trained by previous samples to identify different groups implemented with naïve bayes algorithm"
|
13
|
+
spec.homepage = "https://rubygems.org/gems/nb_class"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake", '~> 0'
|
23
|
+
spec.add_development_dependency "rspec", '~> 0'
|
24
|
+
spec.add_development_dependency "debugger", '~> 0'
|
25
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nb_class/classifier'
|
3
|
+
|
4
|
+
describe NBClass::Classifier do
|
5
|
+
context 'categories examples' do
|
6
|
+
it 'should be added as a dynamically created method' do
|
7
|
+
classifier = NBClass::Classifier.new
|
8
|
+
classifier.random_categ << "example 1"
|
9
|
+
classifier.random_categ << "example 2"
|
10
|
+
classifier.random_categ << "example 3"
|
11
|
+
expect(classifier.random_categ.size).to be_eql(3)
|
12
|
+
end
|
13
|
+
it 'should break a phrase into an array of words' do
|
14
|
+
classifier = NBClass::Classifier.new
|
15
|
+
classifier.another_categ << "word1 word2 word3"
|
16
|
+
expect(classifier.another_categ[0]).to be_eql(["word1","word2","word3"])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'element occurrence count' do
|
21
|
+
it 'should count elements occurrence in a category' do
|
22
|
+
classifier = NBClass::Classifier.new
|
23
|
+
classifier.test << 'car tree street truck car'
|
24
|
+
classifier.train
|
25
|
+
expect(classifier.element_occurrence(category: :test, element: 'car')).to be_eql(2)
|
26
|
+
expect(classifier.element_occurrence(category: :test, element: 'tree')).to be_eql(1)
|
27
|
+
expect(classifier.element_occurrence(category: :test, element: 'street')).to be_eql(1)
|
28
|
+
expect(classifier.element_occurrence(category: :test, element: 'truck')).to be_eql(1)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should globally count elements occurrence' do
|
32
|
+
classifier = NBClass::Classifier.new
|
33
|
+
classifier.test_a << 'blue green blue'
|
34
|
+
classifier.test_b << 'black black black blue'
|
35
|
+
classifier.train
|
36
|
+
expect(classifier.element_occurrence(element: 'blue')).to be_eql(3)
|
37
|
+
expect(classifier.element_occurrence(element: 'green')).to be_eql(1)
|
38
|
+
expect(classifier.element_occurrence(element: 'black')).to be_eql(3)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'probability calculation' do
|
43
|
+
let(:classifier) { NBClass::Classifier.new }
|
44
|
+
before do
|
45
|
+
classifier.test_a << 'blue green blue'
|
46
|
+
classifier.test_b << 'black black black blue'
|
47
|
+
classifier.train
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should calculate the probability of an element occurrence given the category' do
|
51
|
+
expect(classifier.element_probability_given_category(category: :test_a, element: 'blue')).to be_eql(2.0 / 3.0)
|
52
|
+
expect(classifier.element_probability_given_category(category: :test_a, element: 'black')).to be_eql(0.000001)
|
53
|
+
expect(classifier.element_probability_given_category(category: :test_a, element: 'green')).to be_eql(1.0 / 3.0)
|
54
|
+
expect(classifier.element_probability_given_category(category: :test_a, element: 'gray')).to be_eql(0.000001)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should calculate the probability of an element occurrence (global context)' do
|
58
|
+
expect(classifier.element_probability('blue')).to be_eql(3.0 / 7.0)
|
59
|
+
expect(classifier.element_probability('black')).to be_eql(3.0 / 7.0)
|
60
|
+
expect(classifier.element_probability('green')).to be_eql(1.0 / 7.0)
|
61
|
+
expect(classifier.element_probability('gray')).to be_eql(0.000001)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should calculate the probability of the category' do
|
65
|
+
expect(classifier.category_probability(:test_a)).to be_eql(1.0 / 2.0)
|
66
|
+
expect(classifier.category_probability(:test_b)).to be_eql(1.0 / 2.0)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
#####################################
|
71
|
+
# P(blue) = 5/10 = 0.5
|
72
|
+
# P(green) = 5/10 = 0.5
|
73
|
+
#####################################
|
74
|
+
# P(blue|A) = 1/5 = 0.2
|
75
|
+
# P(green|A) = 4/5 = 0.8
|
76
|
+
#####################################
|
77
|
+
# P(green|B) = 1/5 = 0.2
|
78
|
+
# P(green|A) = 4/5 = 0.8
|
79
|
+
#####################################
|
80
|
+
# P(A|blue) = 0.5 * ( 0.2/0.5 ) = 0.5 * 0.4 = 0.2
|
81
|
+
# P(A|blue,blue,green) = 0.5 * ( 0.2/0.5 * 0.2/0.5 * 0.8/0.5 ) = 0.128
|
82
|
+
# P(A|blue,green,green) = 0.5 * ( 0.8/0.5 * 0.8/0.5 * 0.2/0.5 ) = 0.512
|
83
|
+
# P(A|green,green,green) = 0.5 * ( 0.8/0.5 * 0.8/0.5 * 0.8/0.5 ) = 2.048
|
84
|
+
#####################################
|
85
|
+
context 'classification' do
|
86
|
+
let(:classifier) { NBClass::Classifier.new }
|
87
|
+
|
88
|
+
before do
|
89
|
+
classifier.test_a << 'green green green green blue'
|
90
|
+
classifier.test_b << 'blue blue blue blue green'
|
91
|
+
classifier.train
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should calculate the probability of an element array to belong to a category' do
|
95
|
+
expect(classifier.category_probability_given_elements(category: :test_a, elements: ['blue'])).to eq(0.2)
|
96
|
+
expect(classifier.category_probability_given_elements(category: :test_a, elements: ['blue', 'blue', 'green'])).to eq(0.12800000000000003)
|
97
|
+
expect(classifier.category_probability_given_elements(category: :test_a, elements: ['blue', 'green', 'green'])).to eq(0.5120000000000001)
|
98
|
+
expect(classifier.category_probability_given_elements(category: :test_a, elements: ['green', 'green', 'green'])).to eq(2.0480000000000005)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should return the most probable category for an element array' do
|
102
|
+
expect(classifier.classify('blue')).to eq(:test_b)
|
103
|
+
expect(classifier.classify('blue blue green')).to eq(:test_b)
|
104
|
+
expect(classifier.classify('blue green green')).to eq(:test_a)
|
105
|
+
expect(classifier.classify('green green green')).to eq(:test_a)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nb_class/phrase_array'
|
3
|
+
|
4
|
+
describe NBClass::PhraseArray do
|
5
|
+
context 'phrase inclusion' do
|
6
|
+
it 'should be done with operator <<' do
|
7
|
+
phrase_array = NBClass::PhraseArray.new
|
8
|
+
phrase_array << "this is statement 1"
|
9
|
+
phrase_array << "this is statement 2"
|
10
|
+
phrase_array << "this is statement 3"
|
11
|
+
expect(phrase_array.size).to be_eql(3)
|
12
|
+
end
|
13
|
+
it 'should break included phrase as an array of words' do
|
14
|
+
phrase_array = NBClass::PhraseArray.new
|
15
|
+
phrase_array << "this is another phrase"
|
16
|
+
expect(phrase_array.size).to be_eql(1)
|
17
|
+
expect(phrase_array[0].size).to be_eql(4)
|
18
|
+
expect(phrase_array[0][0]).to be_eql('this')
|
19
|
+
expect(phrase_array[0][1]).to be_eql('is')
|
20
|
+
expect(phrase_array[0][2]).to be_eql('another')
|
21
|
+
expect(phrase_array[0][3]).to be_eql('phrase')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
context 'phrase and word access' do
|
25
|
+
it 'should allow to interate through each phrase and word' do
|
26
|
+
phrase_array = NBClass::PhraseArray.new
|
27
|
+
phrase_array << "statement 1"
|
28
|
+
phrase_array << "statement 2"
|
29
|
+
phrase_array << "statement 3"
|
30
|
+
expected_values = [
|
31
|
+
["statement", "1"],
|
32
|
+
["statement", "2"],
|
33
|
+
["statement", "3"]
|
34
|
+
]
|
35
|
+
i = 0
|
36
|
+
j = 0
|
37
|
+
phrase_array.each do |phrase|
|
38
|
+
phrase.each do |word|
|
39
|
+
expect(word).to be_eql(expected_values[i][j])
|
40
|
+
j = j + 1
|
41
|
+
end
|
42
|
+
j = 0;
|
43
|
+
i = i + 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nb_class/utils'
|
3
|
+
|
4
|
+
describe NBClass::Utils do
|
5
|
+
context 'string break in words' do
|
6
|
+
it 'should be brokwn in array of words and remove punctuation marks' do
|
7
|
+
phrase = "word1, word2? word3! word4: word5; word6. word7 word8/ word9|"
|
8
|
+
expected_array = ["word1", "word2", "word3", "word4", "word5", "word6", "word7", "word8", "word9"]
|
9
|
+
actual_array = NBClass::Utils.break_phrase_in_word_array(phrase)
|
10
|
+
expect(actual_array).to be_eql(expected_array)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nb_class
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Humberto Marchezi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: debugger
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Machine learning text classifier
|
70
|
+
email:
|
71
|
+
- hcmarchezi@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/nb_class.rb
|
82
|
+
- lib/nb_class/classifier.rb
|
83
|
+
- lib/nb_class/error/category_name_already_exists.rb
|
84
|
+
- lib/nb_class/error/invalid_category_name.rb
|
85
|
+
- lib/nb_class/phrase_array.rb
|
86
|
+
- lib/nb_class/utils.rb
|
87
|
+
- lib/nb_class/version.rb
|
88
|
+
- nb_class.gemspec
|
89
|
+
- spec/nb_class/classifier_spec.rb
|
90
|
+
- spec/nb_class/phrase_array_spec.rb
|
91
|
+
- spec/nb_class/utils_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
homepage: https://rubygems.org/gems/nb_class
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.4.8
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: This gem offers a simplified interface to allow a text classifier to be trained
|
117
|
+
by previous samples to identify different groups implemented with naïve bayes algorithm
|
118
|
+
test_files:
|
119
|
+
- spec/nb_class/classifier_spec.rb
|
120
|
+
- spec/nb_class/phrase_array_spec.rb
|
121
|
+
- spec/nb_class/utils_spec.rb
|
122
|
+
- spec/spec_helper.rb
|