Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python KMeans init自身质心_Python_Scikit Learn_K Means - Fatal编程技术网

Python KMeans init自身质心

Python KMeans init自身质心,python,scikit-learn,k-means,Python,Scikit Learn,K Means,我想用先前计算的质心初始化KMeans。这里是我的质心: [[ 0.6015258 8.17956199 0.12919147 3.59169105 1.64488952 1.24190854] [ 12.84438984 181.76167076 0.22235872 456.31326781 5.97379197 39.55610156] [ 5.25691959 105.38839179 0.24659986

我想用先前计算的质心初始化KMeans。这里是我的质心:

[[   0.6015258     8.17956199    0.12919147    3.59169105    1.64488952
     1.24190854]
 [  12.84438984  181.76167076    0.22235872  456.31326781    5.97379197
    39.55610156]
 [   5.25691959  105.38839179    0.24659986   69.29062276    7.92543546
    10.66935099]
 [  22.04545455  708.99242424    0.29040404  926.11616162   15.83585859
    45.92929293]
 [  23.45454545 1801.37878788    0.28787879  615.8030303    20.71212121
    39.96969697]]
我的KMeans初始化:

clustering_kmeans = KMeans(n_clusters=5, init=centroids).fit(data)
centers = clustering_kmeans.cluster_centers_
print(centers)
我收到了这个:

[[   1.52026287   20.61007667    2.63745893    9.59474261    8.93975904   6.06900329]
 [  15.5         117.41666667    4.25        393.41666667   15.16666667   152.25      ]
 [   7.86885246  215.83606557    9.18032787   62.95081967   50.13114754   27.73770492]
 [  31.2         160.2           6.         1031.2          18.2           325.8       ]
 [  59.         1419.           11.         1838.           81.           369.        ]]

中心不应该相同吗?

取决于质心的精确程度。如果它们不够精确,
KMeans.fit
将适当调整它们。为什么初始质心应该与最终质心相同?只是好奇,如果使用新的
cluster\u centers\u
初始化
KMeans
,中心是否会再次改变?取决于质心的精确程度。如果它们不够精确,
KMeans.fit
将适当地调整它们。为什么初始质心应该与最终质心相同?只是好奇,如果您使用新的
cluster\u centers\u
初始化
KMeans
,中心会再次改变吗?