I am grouping rows of an NxM matrix using kmeans .
clustIdx = kmeans(data, N_CLUST, 'EmptyAction', 'drop');
Then I rebuild the rows of my matrix so that the adjacent rows are in the same cluster
dataClustered = data(clustIdx,:);
However, every time I run cluster analysis, I get more or less the same clusters, but with different identifiers. Thus, the structure in dataClustered looks the same after each iteration, but the groups are in different orders.
I would like to reorder my cluster identifiers so that lower cluster identifiers represent dense clusters and higher numbers represent rare clusters.
Is there an easy and / or intuitive way to do this?
T. Conversion
clustIdx = [1 2 3 2 3 2 4 4 4 4];
to
clustIdx = [4 2 3 2 3 2 1 1 1 1]
Identities in themselves are arbitrary; information is contained in a grouping.
source share