flock 0.3.0 → 0.3.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.
- data/README.rdoc +29 -11
- data/VERSION +1 -1
- data/flock.gemspec +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@ Provides bindings to K-Means clustering in Cluster 3.0
|
|
12
12
|
|
13
13
|
require 'pp'
|
14
14
|
require 'flock'
|
15
|
-
|
15
|
+
|
16
16
|
data = Array.new(13) {[]}
|
17
17
|
mask = Array.new(13) {[]}
|
18
18
|
weights = Array.new(13) {1.0}
|
@@ -30,7 +30,7 @@ Provides bindings to K-Means clustering in Cluster 3.0
|
|
30
30
|
data[10][ 0]=3.8; data[10][ 1]=3.5; data[10][ 2]=5.5; data[10][ 3] = 9.6;
|
31
31
|
data[11][ 0]=0.0; data[11][ 1]=2.3; data[11][ 2]=3.6; data[11][ 3] = 8.5;
|
32
32
|
data[12][ 0]=4.1; data[12][ 1]=4.5; data[12][ 2]=5.8; data[12][ 3] = 7.6;
|
33
|
-
|
33
|
+
|
34
34
|
mask[ 0][ 0]=1; mask[ 0][ 1]=1; mask[ 0][ 2]=1; mask[ 0][ 3] = 1;
|
35
35
|
mask[ 1][ 0]=1; mask[ 1][ 1]=1; mask[ 1][ 2]=0; mask[ 1][ 3] = 1;
|
36
36
|
mask[ 2][ 0]=1; mask[ 2][ 1]=1; mask[ 2][ 2]=0; mask[ 2][ 3] = 1;
|
@@ -44,13 +44,13 @@ Provides bindings to K-Means clustering in Cluster 3.0
|
|
44
44
|
mask[10][ 0]=1; mask[10][ 1]=1; mask[10][ 2]=1; mask[10][ 3] = 1;
|
45
45
|
mask[11][ 0]=0; mask[11][ 1]=1; mask[11][ 2]=1; mask[11][ 3] = 1;
|
46
46
|
mask[12][ 0]=1; mask[12][ 1]=1; mask[12][ 2]=1; mask[12][ 3] = 1;
|
47
|
-
|
47
|
+
|
48
48
|
pp Flock.kmeans(6, data, mask)
|
49
49
|
|
50
|
-
# method:
|
50
|
+
# method:
|
51
51
|
# - Flock::METHOD_AVERAGE (default)
|
52
52
|
# - Flock::METHOD_MEDIAN
|
53
|
-
# metric:
|
53
|
+
# metric:
|
54
54
|
# - Flock::METRIC_EUCLIDIAN (default)
|
55
55
|
# - Flock::METRIC_CITY_BLOCK
|
56
56
|
# - Flock::METRIC_CORRELATION
|
@@ -63,7 +63,7 @@ Provides bindings to K-Means clustering in Cluster 3.0
|
|
63
63
|
6,
|
64
64
|
data,
|
65
65
|
mask,
|
66
|
-
method: Flock::
|
66
|
+
method: Flock::METHOD_AVERAGE,
|
67
67
|
metric: Flock::METRIC_EUCLIDIAN,
|
68
68
|
transpose: 0,
|
69
69
|
weights: Array.new(13) {1.0},
|
@@ -74,7 +74,7 @@ Provides bindings to K-Means clustering in Cluster 3.0
|
|
74
74
|
|
75
75
|
require 'pp'
|
76
76
|
require 'flock'
|
77
|
-
|
77
|
+
|
78
78
|
data = []
|
79
79
|
|
80
80
|
# keys don't need to be numeric
|
@@ -83,7 +83,7 @@ Provides bindings to K-Means clustering in Cluster 3.0
|
|
83
83
|
data << { 4 => 1, 5 => 0.3 }
|
84
84
|
data << { 2 => 0.75 }
|
85
85
|
data << { 1 => 0.60 }
|
86
|
-
|
86
|
+
|
87
87
|
pp Flock.sparse_kmeans(2, data)
|
88
88
|
|
89
89
|
data = []
|
@@ -94,14 +94,32 @@ Provides bindings to K-Means clustering in Cluster 3.0
|
|
94
94
|
data << %w(white cyan)
|
95
95
|
data << %w(orange)
|
96
96
|
data << %w(apple)
|
97
|
-
|
97
|
+
|
98
|
+
# additional options such as metric, iterations can be passed in a hash.
|
98
99
|
pp Flock.sparse_kmeans(2, data)
|
99
|
-
|
100
|
+
|
101
|
+
=== Self-Organizing Map
|
102
|
+
|
103
|
+
require 'pp'
|
104
|
+
require 'flock'
|
105
|
+
|
106
|
+
data = []
|
107
|
+
|
108
|
+
# a much simpler way to cluster text
|
109
|
+
data << %w(apple orange)
|
110
|
+
data << %w(black white)
|
111
|
+
data << %w(white cyan)
|
112
|
+
data << %w(orange)
|
113
|
+
data << %w(apple)
|
114
|
+
|
115
|
+
# nxgrid, nygrid, data are required.
|
116
|
+
# additional options such as metric, iterations can be passed in a hash.
|
117
|
+
pp Flock.sparse_self_organizing_map(2, 2, data)
|
118
|
+
|
100
119
|
== TODO
|
101
120
|
|
102
121
|
Bindings to,
|
103
122
|
|
104
|
-
* Self Organizing Maps (SOM)
|
105
123
|
* Hierarchical clustering (treecluster)
|
106
124
|
|
107
125
|
= License
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/flock.gemspec
CHANGED