Clustering

1 view (last 30 days)
shyam Kumar
shyam Kumar on 3 Apr 2011
Answered: VM Sreeram on 27 Jun 2023
Hi,
I need to cluster the coordinates of 400 cells into 20 clusters with each cluster HAVING THE SAME NUMBER OF ELEMENTS. Is it possible to do this by kmeans. Can K means ensure that each cluster has the same number of elements ?
thanks in advance,
Shyam

Answers (1)

VM Sreeram
VM Sreeram on 27 Jun 2023
k-means clustering, is an algorithm that assigns n observations to exactly one of k clusters defined by centroids, where k is chosen before the algorithm starts [1].
It means that even we run k-means with k = 400/20 = 20, it does not guarentee that each cluster has equal number of elements.
If you want to ensure that each cluster has equal number of elements, you may run a post-processing step, wherein you reassign datapoints between clusters to balance the cluster sizes. One approach is to iteratively reassign the data points from the largest clusters to the smallest clusters until all clusters have the desired number of elements.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!