kmeans 0.0.7 → 0.0.8
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/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/ChangeLog +5 -0
- data/kmeans.gemspec +2 -2
- data/lib/kmeans.rb +1 -1
- data/lib/kmeans/cluster.rb +1 -1
- data/script/build +3 -0
- data/spec/lib/kmeans/cluster_spec.rb +106 -0
- data/spec/lib/kmeans_spec.rb +1 -1
- metadata +2 -2
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/doc/ChangeLog
CHANGED
data/kmeans.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "kmeans"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["id774"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-03-19"
|
13
13
|
s.description = "K-means clustering"
|
14
14
|
s.email = "idnanashi@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/kmeans.rb
CHANGED
data/lib/kmeans/cluster.rb
CHANGED
data/script/build
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
#
|
6
6
|
# Maintainer: id774 <idnanashi@gmail.com>
|
7
7
|
#
|
8
|
+
# v1.1 3/14,2013
|
9
|
+
# Show ruby version.
|
8
10
|
# v1.0 3/16,2012
|
9
11
|
# First.
|
10
12
|
########################################################################
|
@@ -12,6 +14,7 @@
|
|
12
14
|
kickstart() {
|
13
15
|
export RACK_ROOT="."
|
14
16
|
export RACK_ENV="test"
|
17
|
+
ruby -v
|
15
18
|
}
|
16
19
|
|
17
20
|
run_tests() {
|
@@ -69,6 +69,72 @@ describe Kmeans::Cluster do
|
|
69
69
|
"piyo"=>1
|
70
70
|
}
|
71
71
|
}
|
72
|
+
|
73
|
+
@string_hash = {
|
74
|
+
"test01"=>
|
75
|
+
{"hoge"=>"0",
|
76
|
+
"fuga"=>"1",
|
77
|
+
"piyo"=>"0"
|
78
|
+
},
|
79
|
+
"test02"=>
|
80
|
+
{"hoge"=>"2",
|
81
|
+
"fuga"=>"1",
|
82
|
+
"piyo"=>"3"
|
83
|
+
},
|
84
|
+
"test03"=>
|
85
|
+
{"hoge"=>"3",
|
86
|
+
"fuga"=>"0",
|
87
|
+
"piyo"=>"1"
|
88
|
+
},
|
89
|
+
"test04"=>
|
90
|
+
{"hoge"=>"0",
|
91
|
+
"fuga"=>"2",
|
92
|
+
"piyo"=>"0"
|
93
|
+
},
|
94
|
+
"test05"=>
|
95
|
+
{"hoge"=>"4",
|
96
|
+
"fuga"=>"2",
|
97
|
+
"piyo"=>"3"
|
98
|
+
},
|
99
|
+
"test06"=>
|
100
|
+
{"hoge"=>"3",
|
101
|
+
"fuga"=>"1",
|
102
|
+
"piyo"=>"1"
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
@porous_hash = {
|
107
|
+
"test01"=>
|
108
|
+
{"hoge"=>"0",
|
109
|
+
"fuga"=>"1",
|
110
|
+
"piyo"=>nil
|
111
|
+
},
|
112
|
+
"test02"=>
|
113
|
+
{"hoge"=>"2",
|
114
|
+
"fuga"=>"1",
|
115
|
+
"piyo"=>"3"
|
116
|
+
},
|
117
|
+
"test03"=>
|
118
|
+
{"hoge"=>"3",
|
119
|
+
"fuga"=>nil,
|
120
|
+
"piyo"=>"1"
|
121
|
+
},
|
122
|
+
"test04"=>
|
123
|
+
{"hoge"=>nil,
|
124
|
+
"fuga"=>"2",
|
125
|
+
"piyo"=>nil
|
126
|
+
},
|
127
|
+
"test05"=>
|
128
|
+
{"hoge"=>"4",
|
129
|
+
"fuga"=>"2",
|
130
|
+
"piyo"=>"3"
|
131
|
+
},
|
132
|
+
nil=>
|
133
|
+
{"hoge"=>"3",
|
134
|
+
"fuga"=>"1",
|
135
|
+
nil=>"1"
|
136
|
+
},
|
137
|
+
}
|
72
138
|
end
|
73
139
|
|
74
140
|
context 'の Cluster クラスにおいて' do
|
@@ -111,5 +177,45 @@ describe Kmeans::Cluster do
|
|
111
177
|
result.cluster.values.class.should be_equal Array
|
112
178
|
end
|
113
179
|
end
|
180
|
+
|
181
|
+
describe 'カウント部分が文字列な二次元ハッシュを渡しても' do
|
182
|
+
it "Kmeans::Cluster クラスが返却される" do
|
183
|
+
result = Kmeans::Cluster.new(@string_hash, {
|
184
|
+
:centroids => 5,
|
185
|
+
:loop_max => 10
|
186
|
+
})
|
187
|
+
result.class.should be_equal Kmeans::Cluster
|
188
|
+
end
|
189
|
+
|
190
|
+
it "ハッシュの配列が返却される (結果は実行ごとに異なる)" do
|
191
|
+
result = Kmeans::Cluster.new(@string_hash, {
|
192
|
+
:centroids => 5,
|
193
|
+
:loop_max => 10
|
194
|
+
})
|
195
|
+
result.make_cluster
|
196
|
+
result.cluster.class.should be_equal Hash
|
197
|
+
result.cluster.values.class.should be_equal Array
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe 'nil を含む二次元ハッシュを渡しても' do
|
202
|
+
it "Kmeans::Cluster クラスが返却される" do
|
203
|
+
result = Kmeans::Cluster.new(@porous_hash, {
|
204
|
+
:centroids => 5,
|
205
|
+
:loop_max => 10
|
206
|
+
})
|
207
|
+
result.class.should be_equal Kmeans::Cluster
|
208
|
+
end
|
209
|
+
|
210
|
+
it "ハッシュの配列が返却される (結果は実行ごとに異なる)" do
|
211
|
+
result = Kmeans::Cluster.new(@porous_hash, {
|
212
|
+
:centroids => 5,
|
213
|
+
:loop_max => 10
|
214
|
+
})
|
215
|
+
result.make_cluster
|
216
|
+
result.cluster.class.should be_equal Hash
|
217
|
+
result.cluster.values.class.should be_equal Array
|
218
|
+
end
|
219
|
+
end
|
114
220
|
end
|
115
221
|
end
|
data/spec/lib/kmeans_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kmeans
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|