Manuel
Manuel

Reputation: 1

K-means clustering Matlab

My problem is that it is difficult to get the optimal cluster number by using k-means, so I thought of using a hierarchical algorithm to find the optimal cluster number. After defining my ideal classification I want to use this classification to find the centroids with k-means, without iteration.

data= rand(300,5);
D = pdist(data);
Z = linkage(D,'ward');
T = cluster(Z,'maxclust',6);

Now I want to use the clusters defined in vector T and the positions in to k-means algorithm without iterations. Can anyone give a tip how to do?

Thank you.

Upvotes: 0

Views: 1286

Answers (1)

Shai
Shai

Reputation: 114796

If you are looking for the centroids given that you already clustered them in T, then you only need to compute the mean of data grouped according to T.

Upvotes: 1

Related Questions