random.seed(self.random_state)# 初始化聚类中心ifself.centersisNone:# 随机选取簇心(这点可改进,比如kmeans++就是在此改进的)idx = idx = random.sample(range(n_samples),self.K)self.centers = X[idx, :]# 初始样本的族标记-1pred = np.array([-1]*n_samples)iter=0stop =False# 结束标志whil...