Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing issue w/ Naive Bayes implemtation - bumped version to 0.0.14

  • Loading branch information...
commit 7070bb3098bf506cc610a7f8ca76125a1d32ecf3 1 parent 19108a5
@bmuller bmuller authored
View
2  .rvmrc
@@ -0,0 +1,2 @@
+rvm --create ruby-1.9.2-p0@ankusa
+
View
4 Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in bandit.gemspec
+gemspec
View
16 Gemfile.lock
@@ -0,0 +1,16 @@
+PATH
+ remote: .
+ specs:
+ ankusa (0.0.14)
+ fast-stemmer (>= 1.0.0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ fast-stemmer (1.0.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ ankusa!
View
10 Rakefile
@@ -15,35 +15,35 @@ RDoc::Task.new("doc") { |rdoc|
desc "Run all unit tests with memory storage"
Rake::TestTask.new("test_memory") { |t|
- t.libs << "lib"
+ t.libs += ["lib", "."]
t.test_files = FileList['test/hasher_test.rb', 'test/memory_classifier_test.rb']
t.verbose = true
}
desc "Run all unit tests with HBase storage"
Rake::TestTask.new("test_hbase") { |t|
- t.libs << "lib"
+ t.libs += ["lib", "."]
t.test_files = FileList['test/hasher_test.rb']
t.verbose = true
}
desc "Run all unit tests with Cassandra storage"
Rake::TestTask.new("test_cassandra") { |t|
- t.libs << "lib"
+ t.libs += ["lib", "."]
t.test_files = FileList['test/hasher_test.rb', 'test/cassandra_classifier_test.rb']
t.verbose = true
}
desc "Run all unit tests with FileSystem storage"
Rake::TestTask.new("test_filesystem") { |t|
- t.libs << "lib"
+ t.libs += ["lib", "."]
t.test_files = FileList['test/hasher_test.rb', 'test/file_system_classifier_test.rb']
t.verbose = true
}
desc "Run all unit tests with MongoDb storage"
Rake::TestTask.new("test_mongo_db") { |t|
- t.libs << "lib"
+ t.libs += ["lib", "."]
t.test_files = FileList['test/hasher_test.rb', 'test/mongo_db_classifier_test.rb']
t.verbose = true
}
View
6 lib/ankusa/naive_bayes.rb
@@ -13,7 +13,7 @@ def classify(text, classes=nil)
def classifications(text, classnames=nil)
result = log_likelihoods text, classnames
result.keys.each { |k|
- result[k] = (result[k] == INFTY) ? 0 : Math.exp(result[k])
+ result[k] = (result[k] == -INFTY) ? 0 : Math.exp(result[k])
}
# normalize to get probs
@@ -30,8 +30,8 @@ def log_likelihoods(text, classnames=nil)
TextHash.new(text).each { |word, count|
probs = get_word_probs(word, classnames)
classnames.each { |k|
- # log likelihood should be infinity if we've never seen the klass
- result[k] += probs[k] > 0 ? (Math.log(probs[k]) * count) : INFTY
+ # log likelihood should be negative infinity if we've never seen the klass
+ result[k] += probs[k] > 0 ? (Math.log(probs[k]) * count) : -INFTY
}
}
View
2  lib/ankusa/version.rb
@@ -1,3 +1,3 @@
module Ankusa
- VERSION = "0.0.13"
+ VERSION = "0.0.14"
end
Please sign in to comment.
Something went wrong with that request. Please try again.