distance_measures 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/distance_measures.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{distance_measures}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["reddavis"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-26}
|
13
13
|
s.description = %q{A bundle of distance measures}
|
14
14
|
s.email = %q{reddavis@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -2,6 +2,8 @@
|
|
2
2
|
module DistanceMeasures
|
3
3
|
def tanimoto_coefficient(other)
|
4
4
|
dot = self.dot_product(other).to_f
|
5
|
-
dot / (self.sum_of_squares + other.sum_of_squares - dot).to_f
|
5
|
+
result = dot / (self.sum_of_squares + other.sum_of_squares - dot).to_f
|
6
|
+
|
7
|
+
handle_nan(result)
|
6
8
|
end
|
7
9
|
end
|
@@ -12,12 +12,20 @@ describe "DistanceMeasures" do
|
|
12
12
|
it "should return 1.0" do
|
13
13
|
array.cosine_similarity(array).should > 0.99
|
14
14
|
end
|
15
|
+
|
16
|
+
it "should handle NaN's" do
|
17
|
+
[0.0, 0.0].cosine_similarity([0.0, 0.0]).nan?.should be_false
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
describe "Tanimoto Coefficient" do
|
18
22
|
it "should return 1.0" do
|
19
23
|
array.tanimoto_coefficient(array).should == 1.0
|
20
24
|
end
|
25
|
+
|
26
|
+
it "should handle NaN's" do
|
27
|
+
[0.0, 0.0].tanimoto_coefficient([0.0, 0.0]).nan?.should be_false
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
31
|
describe "Sum of Squares" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distance_measures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- reddavis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-26 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|