k-means - get the sizes of clusters and every element in a cluster #3663
Replies: 4 comments
-
|
Beta Was this translation helpful? Give feedback.
-
As far as I'm concerned, it just shows the histogram of each element in the whole 180K vector's appearing count, but not actually the sizes of clusters and every element in a cluster |
Beta Was this translation helpful? Give feedback.
-
Oops, btw you can use the tools mentioned here: https://github.com/facebookresearch/faiss/wiki/Faiss-building-blocks:-clustering,-PCA,-quantization#assignment |
Beta Was this translation helpful? Give feedback.
-
I'm not sure @Lorisyy's link has the answer to @varvaralitvinova's question, but for getting counts, we can do: from collections import Counter
counter = Counter()
for c in I.reshape(-1):
counter[c] += 1
sorted(counter.items()) Returns:
However, it'd really be nice to have a built-in method to extract the elements of each cluster easily. |
Beta Was this translation helpful? Give feedback.
-
I have used k-means clustering on 180K vectors, I have 20 clusters and I would like to see how many elements each cluster contains. How can I do that?
Beta Was this translation helpful? Give feedback.
All reactions