Query regarding k-means clustering in MATLAB

前端 未结 2 492
-上瘾入骨i
-上瘾入骨i 2020-12-12 07:51

I have a very large amount of data in the form of matrix.I have already clustered it using k-means clustering in MATLAB R2013a. I want the exact coordinates of the centroid

相关标签:
2条回答
  • 2020-12-12 08:29

    The centroid is simply evaluated as the average value of all the points' coordinates that are assigned to that cluster.

    If you have the assignments {point;cluster} you can easily evaluate the centroid: let's say you have a given cluster with n points assigned to it and these points are a1,a2,...,an. You can evaluate the centroid for such cluster by using:

    centroid=(a1+a2+...+an)/n
    

    Obviously you can run this process in a loop, depending on how your data structure (i.e. the assignment point/centroid) is organized.

    0 讨论(0)
  • 2020-12-12 08:41

    In MATLAB, use

    [idx,C] = kmeans(..) 
    

    instead of

    idx = kmeans(..) 
    

    As per the documentation:

    [idx,C] = kmeans(..) returns the k cluster centroid locations in the k-by-p matrix C.

    0 讨论(0)
提交回复
热议问题