fix: fix corner case with noisy samples only

This commit is contained in:
Hervé BREDIN committed 2022-09-07 22:48:53 +02:00
1 parent 5534a76123
commit 5f9d416dae
1 file changed
+3
+3
View File
@@ -450,6 +450,9 @@ class DBSCANClustering(BaseClustering):
)
num_clusters = np.max(clusters) + 1
if num_clusters < 1:
return np.zeros((num_embeddings,), dtype=np.uint8)
# assign noisy samples to closest centroid
centroids = np.vstack(
[np.mean(embeddings[clusters == k], axis=0) for k in range(num_clusters)]