sklearn KMeans中的KMeans.cluster_centers_的值 [英] Value at KMeans.cluster_centers_ in sklearn KMeans

查看:1028
本文介绍了sklearn KMeans中的KMeans.cluster_centers_的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在进行K表示适合具有3个簇的某些向量时,我能够获得输入数据的标签. KMeans.cluster_centers_返回中心的坐标,因此不应该有一些与之相对应的矢量吗?如何找到这些聚类的质心处的值?

On doing K means fit on some vectors with 3 clusters, I was able to get the labels for the input data. KMeans.cluster_centers_ returns the coordinates of the centers and so shouldn't there be some vector corresponding to that? How can I find the value at the centroid of these clusters?

推荐答案

closest, _ = pairwise_distances_argmin_min(KMeans.cluster_centers_, X)

数组closest将包含X中最接近每个质心的点的索引.

The array closest will contain the index of the point in X that is closest to each centroid.

假设closest给出了三个群集的输出为array([0,8,5]).因此,X [0]是X中最接近质心0的点,X [8]是最接近质心1的点,依此类推.

Let's say the closest gave output as array([0,8,5]) for the three clusters. So X[0] is the closest point in X to centroid 0, and X[8] is the closest to centroid 1 and so on.

来源: https://codedump. io/share/XiME3OAGY5Tm/1/get-nearestpoint-to-centroid-scikit-learn

这篇关于sklearn KMeans中的KMeans.cluster_centers_的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆