sklearn KMeans中的KMeans.cluster_centers_的值 [英] Value at KMeans.cluster_centers_ in sklearn KMeans
问题描述
在进行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屋!