k_means 0.0.4 → 0.0.5
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.
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/k_means.gemspec +1 -1
- data/lib/k_means/k_means.rb +2 -2
- data/test/k_means/test_centroid.rb +1 -1
- data/test/k_means/test_k_means.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -38,9 +38,9 @@ The measurements currently available are:
|
|
38
38
|
|
39
39
|
To specify a particular one to use in the KMeans algorithm, just provide it as an option:
|
40
40
|
|
41
|
-
KMeans.new(@data, :
|
42
|
-
KMeans.new(@data, :
|
43
|
-
KMeans.new(@data, :
|
41
|
+
KMeans.new(@data, :distance_measure => :jaccard_index)
|
42
|
+
KMeans.new(@data, :distance_measure => :cosine_similarity)
|
43
|
+
KMeans.new(@data, :distance_measure => :tanimoto_coefficient)
|
44
44
|
|
45
45
|
You get the idea...
|
46
46
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/k_means.gemspec
CHANGED
data/lib/k_means/k_means.rb
CHANGED
@@ -8,8 +8,8 @@ class KMeans
|
|
8
8
|
k = options[:centroids] || 4
|
9
9
|
@verbose = options[:verbose]
|
10
10
|
|
11
|
-
|
12
|
-
@nodes = Node.create_nodes(data,
|
11
|
+
distance_measure = options[:distance_measure] || :euclidean_distance
|
12
|
+
@nodes = Node.create_nodes(data, distance_measure)
|
13
13
|
@centroids = Centroid.create_centroids(k, @nodes)
|
14
14
|
|
15
15
|
perform_cluster_process
|
@@ -5,7 +5,7 @@ class TestKMeans < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
setup do
|
7
7
|
@data = Array.new(200) {Array.new(2) {rand}}
|
8
|
-
@kmeans = KMeans.new(@data, :centroids => 2, :
|
8
|
+
@kmeans = KMeans.new(@data, :centroids => 2, :distance_measure => :cosine_similarity)
|
9
9
|
end
|
10
10
|
|
11
11
|
should "return an array" do
|