carmenere 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/carmenere/kmeans/algorithm.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02670cf89b4e3e98bbe7faa4475d63ca69307faa
|
4
|
+
data.tar.gz: a1e0bf72e95c5249d1cd361f83f6624a782fd4e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f472978df468b8b2dd5be7cace20c8f183406a48bfd1b8f965471c909e47790d4d8f54823a715e60c22aebb7110c5b02c7f8ec540b23c2e432c0a978c9a23043
|
7
|
+
data.tar.gz: 947929656f9cf8bef320540553568fb1438564732f6ade88cda44955d4af5bbc2e66c665dd0fd5f0fa712a0f4704721d139ac087a5afcf9ae6054fecb8e2c117
|
@@ -4,9 +4,13 @@ module Carmenere::KMeans
|
|
4
4
|
|
5
5
|
def self.centroids_eql? old_centroids, new_centroids
|
6
6
|
[old_centroids, new_centroids].each do |i|
|
7
|
-
unless i.is_a?(Set)
|
7
|
+
unless i.is_a?(Set)
|
8
8
|
raise TypeError.new("#{i.class} is not Set of Node")
|
9
9
|
end
|
10
|
+
unless i.all?{ |j| j.is_a?(Carmenere::Node) }
|
11
|
+
types = i.map{|j| j.class}
|
12
|
+
raise TypeError.new("Elements of Cluster are of types #{types}")
|
13
|
+
end
|
10
14
|
end
|
11
15
|
old_centroids.count == new_centroids.count and old_centroids.all? do |i|
|
12
16
|
new_centroids.any? do |j|
|
@@ -45,9 +49,12 @@ module Carmenere::KMeans
|
|
45
49
|
h[centroid] = Carmenere::KMeans::Cluster.new nodes
|
46
50
|
end
|
47
51
|
yield centroid_clusters if block_given?
|
48
|
-
centroids =
|
52
|
+
centroids = centroid_clusters.values.reject do |cluster|
|
53
|
+
cluster.empty?
|
54
|
+
end.map do |cluster|
|
49
55
|
@mean.call(cluster)
|
50
56
|
end
|
57
|
+
centroids = Set.new centroids
|
51
58
|
end
|
52
59
|
centroid_clusters
|
53
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carmenere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnny Lee Othon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Cluster algorithms
|
14
14
|
email: jleeothon@gmail.com
|