Skip to content

Commit ac9ab72

Browse files
committed
Pushing the docs for revision for branch: master, commit a747d32d4200aad4cbc487c411534c4a79a33af4
1 parent 41b5d85 commit ac9ab72

File tree

883 files changed

+2896
-2902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

883 files changed

+2896
-2902
lines changed

dev/_downloads/plot_mini_batch_kmeans.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
t0 = time.time()
4040
k_means.fit(X)
4141
t_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
@@ -51,9 +48,6 @@
5148
t0 = time.time()
5249
mbk.fit(X)
5350
t_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
@@ -65,7 +59,10 @@
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)
6966
order = pairwise_distances_argmin(k_means_cluster_centers,
7067
mbk_means_cluster_centers)
7168

-105 Bytes
-105 Bytes
-401 Bytes
-401 Bytes
-539 Bytes
-539 Bytes
170 Bytes
170 Bytes
724 Bytes

0 commit comments

Comments
 (0)