我想从下面的代码了解惯性

时间:2019-07-28 16:18:05

标签: python python-3.x numpy cluster-analysis

我正在从Kaggle数据集中学习机器学习。我从惯性中找出簇的编号。您能详细说明一下代码吗?我不明白为什么写成inertia_list = np.empty(8),请解释一下行plt.plot(range(0,8),inertia_list,'-o')

inertia_list = np.empty(8)
for i in range(1,8):
    kmeans = KMeans(n_clusters= i)
    kmeans.fit(data2)
    inertia_list[i]=kmeans.inertia_
plt.plot(range(0,8),inertia_list,'-o')
plt.xlabel('Number of Clu`enter code here`ster')
plt.ylabel('Inertia')
plt.show()

0 个答案:

没有答案