cluster_centers_的ordering/index在KMeans聚类SKlearn中代表什么

What does the ordering/index of cluster_centers_ represent in KMeans clustering SKlearn

我实现了以下代码

k_mean = KMeans(n_clusters=5,init=centroids,n_init=1,random_state=SEED).fit(X_input)
k_mean.cluster_centers_.shape
>>
(5, 50)

我有 5 个数据簇。

簇是如何排序的?簇中心的索引是否代表 labels?

表示0th位置的cluster_center索引是否代表label = 0?

docs你有一个微笑的例子:

>>> from sklearn.cluster import KMeans
>>> import numpy as np
>>> X = np.array([[1, 2], [1, 4], [1, 0],
...               [10, 2], [10, 4], [10, 0]])
>>> kmeans = KMeans(n_clusters=2, random_state=0).fit(X)
>>> kmeans.labels_
array([1, 1, 1, 0, 0, 0], dtype=int32)
>>> kmeans.predict([[0, 0], [12, 3]])
array([1, 0], dtype=int32)
>>> kmeans.cluster_centers_
array([[10.,  2.],
       [ 1.,  2.]])

索引是有序的。顺便说一句,k_mean.cluster_centers_.shape你只 return 数组的形状,而不是值。因此,在您的情况下,您有 5 个聚类,特征维度为 50。

最近的点可以看看.