Query regarding k-means clustering in MATLAB

走远了吗. 提交于 2019-11-28 14:52:36
prashanth

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!