Skip to content

Commit 2df4aa9

Browse files
committed
WIP: Updated tested metric support for Hamerly
1 parent aef8f69 commit 2df4aa9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/hamerly.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function update_containers(::Hamerly, containers, centroids, n_threads, metric)
150150
@inbounds for i in axes(centroids, 2)
151151
for j in i+1:size(centroids, 2)
152152
d = distance(metric, centroids, centroids, i, j)
153-
d = T(0.25)*d
153+
d = T(centers_coefficient(metric)) * d
154154
s[i] = s[i] > d ? d : s[i]
155155
s[j] = s[j] > d ? d : s[j]
156156
end

src/kmeans.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,7 @@ function collect_containers(::AbstractKMeansAlg, containers, n_threads)
199199
@inbounds containers.centroids_new[end] .= containers.centroids_new[end] ./ containers.centroids_cnt[end]'
200200
end
201201
end
202+
203+
# Special center co-efficent dispatched on Euclidean or different metrics supported by Distances.jl
204+
centers_coefficient(::Euclidean) = 0.25
205+
centers_coefficient(::Distances.Metric) = 0.5

0 commit comments

Comments
 (0)