You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If medoids have duplicate coordinates, make
sure the medoid is assigned to itself,
otherwise its cluster might be empty.
If the distance to itself is further than to
another medoid, it is an issue with the distance
matrix, and ArgumentError is raised.
fixes#231
Copy file name to clipboardExpand all lines: src/kmedoids.jl
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -206,7 +206,8 @@ function _kmed_update_assignments!(dist::AbstractMatrix{<:Real}, # in: (n, n)
206
206
m = medoids[i]
207
207
v = dist[m, j]
208
208
# assign if current medoid is closer or if it is j itself
209
-
if v < mv
209
+
if (v < mv) || (m == j)
210
+
(v <= mv) ||throw(ArgumentError("sample #$j reassigned from medoid[$p]=#$(medoids[p]) (distance=$mv) to medoid[$i]=#$m (distance=$v); check the distance matrix correctness"))
0 commit comments