【pairwise_distances_argmin】
语法:
示例:
k_means_labels = pairwise_distances_argmin(X, k_means_cluster_centers,axis=1)
X.shape:(3000,2);k_means_cluster_centers.shape:(3,2)
k_means_labels.shape:(3000,)
返回结果是X中的每一行与k_means_cluster_centers中的每一行的沿axis=1的距离,最小的k_means_cluster_centers的序号
k_means_labels = pairwise_distances_argmin(X, k_means_cluster_centers,axis=0)k_means_labels.shape:(3,)
返回结果“像是”k_means_cluster_centers中的每一行对应X中最小距离的行数
为了验证如上假设:
pairwise_distances_argmin(k_means_cluster_centers, X, axis=1)
pairwise_distances_argmin(X, k_means_cluster_centers,axis=0)
两个调用的返回一致,都是:
*************************************************************************************
【sort】
语法:
示例:
mbk_means_cluster_centers = np.sort(mbk.cluster_centers_, axis=0)
mbk.cluster_centers_:shape:(3,2)
mbk.means_cluster_centers: