init_center(K) # randomly set K vector that will be the center of your cluster
while not converge(): # This one is tricky as you can find a lot of way to check for the convergence, the easiest is to check if your center has moved since the last itteration
associate_vector() # Here you associate all the vectors to the closest center
re_calculate_center() # And now you put the center at the... well center of their point, you can do that just by doing the mean of all the vector of the cluster.
不知道你问的是什么,但如果你想要一种方法来检查向量是否属于同一类型,你可以使用K均值。 K-意味着从一个向量列表中选出一个K个簇,所以如果你选择一个好的K(不要太低,它会搜索到一些东西,但是不要太高,所以它不会太有区别),它可以工作。在
K-表示工作非常辛苦:
这个gif可能比我更清楚:
这篇文章(gif的来源)比我更清楚,即使他在这里说的是java: https://picoledelimao.github.io/blog/2016/03/12/multithreaded-k-means-in-java/
相关问题 更多 >
编程相关推荐