File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 3939t0 = time .time ()
4040k_means .fit (X )
4141t_batch = time .time () - t0
42- k_means_labels = k_means .labels_
43- k_means_cluster_centers = k_means .cluster_centers_
44- k_means_labels_unique = np .unique (k_means_labels )
4542
4643##############################################################################
4744# Compute clustering with MiniBatchKMeans
5148t0 = time .time ()
5249mbk .fit (X )
5350t_mini_batch = time .time () - t0
54- mbk_means_labels = mbk .labels_
55- mbk_means_cluster_centers = mbk .cluster_centers_
56- mbk_means_labels_unique = np .unique (mbk_means_labels )
5751
5852##############################################################################
5953# Plot result
6559# We want to have the same colors for the same cluster from the
6660# MiniBatchKMeans and the KMeans algorithm. Let's pair the cluster centers per
6761# closest one.
68-
62+ k_means_cluster_centers = np .sort (k_means .cluster_centers_ , axis = 0 )
63+ mbk_means_cluster_centers = np .sort (mbk .cluster_centers_ , axis = 0 )
64+ k_means_labels = pairwise_distances_argmin (X , k_means_cluster_centers )
65+ mbk_means_labels = pairwise_distances_argmin (X , mbk_means_cluster_centers )
6966order = pairwise_distances_argmin (k_means_cluster_centers ,
7067 mbk_means_cluster_centers )
7168
You can’t perform that action at this time.
0 commit comments