db_clustering 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/algorithms/density_based/dbscan.rb +16 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f960d170fbc8d820ad18016a4ce03943fd02de54
|
4
|
+
data.tar.gz: c257769487f5a8efaa1d2a2606aa1aee51083453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a02139c030777fdcd4ce942fad981682e50f641d5e99e76fd40859a77caa73199869f301b3bb272eae647f72b5a1c0cc967f4a9a535b5e9b229b8d1e25a246a
|
7
|
+
data.tar.gz: 972a4d5b380333a128901d62dc7b28bf8d4f5240f3517e55eb0404e99ccb7e5164299edfb5a55a87e917d58608c45d15896c236caf56c993bbc161a94db65ab0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.11
|
@@ -21,29 +21,28 @@ module DbClustering
|
|
21
21
|
|
22
22
|
if neighbors.count < min_neighbors
|
23
23
|
point.is_noise = true
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
else
|
25
|
+
if point.cluster.nil?
|
26
|
+
cluster = DbClustering::Models::Cluster.new
|
27
|
+
@clusters << cluster
|
28
|
+
else
|
29
|
+
cluster = point.cluster
|
30
|
+
end
|
31
|
+
|
32
|
+
neighbors.each do |neighbor|
|
33
|
+
if neighbor.cluster.nil?
|
34
|
+
cluster.add(neighbor)
|
35
|
+
|
36
|
+
# add the neighbors of the neighbor to the neighbors to fully expand the cluster
|
37
|
+
neighbors |= @datasource.neighbors(point: neighbor, distance_metric: @distance_metric, max_distance: max_distance)
|
38
|
+
end
|
39
|
+
end
|
30
40
|
end
|
31
41
|
|
32
42
|
yield(point, current_index, points_count) if block_given?
|
33
43
|
end
|
34
44
|
end
|
35
45
|
|
36
|
-
def expand_cluster(point, neighbors, max_distance)
|
37
|
-
neighbors.each do |neighbor|
|
38
|
-
if neighbor.cluster.nil?
|
39
|
-
point.cluster.add(neighbor)
|
40
|
-
|
41
|
-
neighbors = @datasource.neighbors(point: point, distance_metric: @distance_metric, max_distance: max_distance)
|
42
|
-
expand_cluster(neighbor, neighbors, max_distance)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|