RuntimeWarning: Mean of empty slice.
是因为len(k_cluster)可能为0
for cent_i in range(k): # 重新计算中心点k_cluster = data[np.nonzero(cluster == cent_i)]# 加上判断if len(k_cluster) != 0:new_cents[cent_i, :] = np.mean(k_cluster, 0)
RuntimeWarning: Mean of empty slice.
是因为len(k_cluster)可能为0
for cent_i in range(k): # 重新计算中心点k_cluster = data[np.nonzero(cluster == cent_i)]# 加上判断if len(k_cluster) != 0:new_cents[cent_i, :] = np.mean(k_cluster, 0)