Skip to content

Commit c97fe6e

Browse files
committed
Pushing the docs to dev/ for branch: master, commit e8ca95616f4f1a28db12b633aa450e9f3d19f575
1 parent 41babf6 commit c97fe6e

File tree

613 files changed

+971
-968
lines changed

Some content is hidden

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

613 files changed

+971
-968
lines changed
Binary file not shown.

dev/_downloads/58afd0669a2190b8c0825a98eb4321d8/plot_mini_batch_kmeans.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@
5959
# We want to have the same colors for the same cluster from the
6060
# MiniBatchKMeans and the KMeans algorithm. Let's pair the cluster centers per
6161
# closest one.
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)
62+
k_means_cluster_centers = k_means.cluster_centers_
63+
order = pairwise_distances_argmin(k_means.cluster_centers_,
64+
mbk.cluster_centers_)
65+
mbk_means_cluster_centers = mbk.cluster_centers_[order]
66+
6467
k_means_labels = pairwise_distances_argmin(X, k_means_cluster_centers)
6568
mbk_means_labels = pairwise_distances_argmin(X, mbk_means_cluster_centers)
66-
order = pairwise_distances_argmin(k_means_cluster_centers,
67-
mbk_means_cluster_centers)
6869

6970
# KMeans
7071
ax = fig.add_subplot(1, 3, 1)
@@ -84,8 +85,8 @@
8485
# MiniBatchKMeans
8586
ax = fig.add_subplot(1, 3, 2)
8687
for k, col in zip(range(n_clusters), colors):
87-
my_members = mbk_means_labels == order[k]
88-
cluster_center = mbk_means_cluster_centers[order[k]]
88+
my_members = mbk_means_labels == k
89+
cluster_center = mbk_means_cluster_centers[k]
8990
ax.plot(X[my_members, 0], X[my_members, 1], 'w',
9091
markerfacecolor=col, marker='.')
9192
ax.plot(cluster_center[0], cluster_center[1], 'o', markerfacecolor=col,
@@ -101,7 +102,7 @@
101102
ax = fig.add_subplot(1, 3, 3)
102103

103104
for k in range(n_clusters):
104-
different += ((k_means_labels == k) != (mbk_means_labels == order[k]))
105+
different += ((k_means_labels == k) != (mbk_means_labels == k))
105106

106107
identic = np.logical_not(different)
107108
ax.plot(X[identic, 0], X[identic, 1], 'w',

dev/_downloads/b547a0f1cb31854154c511c150b4a23f/plot_mini_batch_kmeans.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"print(__doc__)\n\nimport time\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn.cluster import MiniBatchKMeans, KMeans\nfrom sklearn.metrics.pairwise import pairwise_distances_argmin\nfrom sklearn.datasets.samples_generator import make_blobs\n\n# #############################################################################\n# Generate sample data\nnp.random.seed(0)\n\nbatch_size = 45\ncenters = [[1, 1], [-1, -1], [1, -1]]\nn_clusters = len(centers)\nX, labels_true = make_blobs(n_samples=3000, centers=centers, cluster_std=0.7)\n\n# #############################################################################\n# Compute clustering with Means\n\nk_means = KMeans(init='k-means++', n_clusters=3, n_init=10)\nt0 = time.time()\nk_means.fit(X)\nt_batch = time.time() - t0\n\n# #############################################################################\n# Compute clustering with MiniBatchKMeans\n\nmbk = MiniBatchKMeans(init='k-means++', n_clusters=3, batch_size=batch_size,\n n_init=10, max_no_improvement=10, verbose=0)\nt0 = time.time()\nmbk.fit(X)\nt_mini_batch = time.time() - t0\n\n# #############################################################################\n# Plot result\n\nfig = plt.figure(figsize=(8, 3))\nfig.subplots_adjust(left=0.02, right=0.98, bottom=0.05, top=0.9)\ncolors = ['#4EACC5', '#FF9C34', '#4E9A06']\n\n# We want to have the same colors for the same cluster from the\n# MiniBatchKMeans and the KMeans algorithm. Let's pair the cluster centers per\n# closest one.\nk_means_cluster_centers = np.sort(k_means.cluster_centers_, axis=0)\nmbk_means_cluster_centers = np.sort(mbk.cluster_centers_, axis=0)\nk_means_labels = pairwise_distances_argmin(X, k_means_cluster_centers)\nmbk_means_labels = pairwise_distances_argmin(X, mbk_means_cluster_centers)\norder = pairwise_distances_argmin(k_means_cluster_centers,\n mbk_means_cluster_centers)\n\n# KMeans\nax = fig.add_subplot(1, 3, 1)\nfor k, col in zip(range(n_clusters), colors):\n my_members = k_means_labels == k\n cluster_center = k_means_cluster_centers[k]\n ax.plot(X[my_members, 0], X[my_members, 1], 'w',\n markerfacecolor=col, marker='.')\n ax.plot(cluster_center[0], cluster_center[1], 'o', markerfacecolor=col,\n markeredgecolor='k', markersize=6)\nax.set_title('KMeans')\nax.set_xticks(())\nax.set_yticks(())\nplt.text(-3.5, 1.8, 'train time: %.2fs\\ninertia: %f' % (\n t_batch, k_means.inertia_))\n\n# MiniBatchKMeans\nax = fig.add_subplot(1, 3, 2)\nfor k, col in zip(range(n_clusters), colors):\n my_members = mbk_means_labels == order[k]\n cluster_center = mbk_means_cluster_centers[order[k]]\n ax.plot(X[my_members, 0], X[my_members, 1], 'w',\n markerfacecolor=col, marker='.')\n ax.plot(cluster_center[0], cluster_center[1], 'o', markerfacecolor=col,\n markeredgecolor='k', markersize=6)\nax.set_title('MiniBatchKMeans')\nax.set_xticks(())\nax.set_yticks(())\nplt.text(-3.5, 1.8, 'train time: %.2fs\\ninertia: %f' %\n (t_mini_batch, mbk.inertia_))\n\n# Initialise the different array to all False\ndifferent = (mbk_means_labels == 4)\nax = fig.add_subplot(1, 3, 3)\n\nfor k in range(n_clusters):\n different += ((k_means_labels == k) != (mbk_means_labels == order[k]))\n\nidentic = np.logical_not(different)\nax.plot(X[identic, 0], X[identic, 1], 'w',\n markerfacecolor='#bbbbbb', marker='.')\nax.plot(X[different, 0], X[different, 1], 'w',\n markerfacecolor='m', marker='.')\nax.set_title('Difference')\nax.set_xticks(())\nax.set_yticks(())\n\nplt.show()"
29+
"print(__doc__)\n\nimport time\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn.cluster import MiniBatchKMeans, KMeans\nfrom sklearn.metrics.pairwise import pairwise_distances_argmin\nfrom sklearn.datasets.samples_generator import make_blobs\n\n# #############################################################################\n# Generate sample data\nnp.random.seed(0)\n\nbatch_size = 45\ncenters = [[1, 1], [-1, -1], [1, -1]]\nn_clusters = len(centers)\nX, labels_true = make_blobs(n_samples=3000, centers=centers, cluster_std=0.7)\n\n# #############################################################################\n# Compute clustering with Means\n\nk_means = KMeans(init='k-means++', n_clusters=3, n_init=10)\nt0 = time.time()\nk_means.fit(X)\nt_batch = time.time() - t0\n\n# #############################################################################\n# Compute clustering with MiniBatchKMeans\n\nmbk = MiniBatchKMeans(init='k-means++', n_clusters=3, batch_size=batch_size,\n n_init=10, max_no_improvement=10, verbose=0)\nt0 = time.time()\nmbk.fit(X)\nt_mini_batch = time.time() - t0\n\n# #############################################################################\n# Plot result\n\nfig = plt.figure(figsize=(8, 3))\nfig.subplots_adjust(left=0.02, right=0.98, bottom=0.05, top=0.9)\ncolors = ['#4EACC5', '#FF9C34', '#4E9A06']\n\n# We want to have the same colors for the same cluster from the\n# MiniBatchKMeans and the KMeans algorithm. Let's pair the cluster centers per\n# closest one.\nk_means_cluster_centers = k_means.cluster_centers_\norder = pairwise_distances_argmin(k_means.cluster_centers_,\n mbk.cluster_centers_)\nmbk_means_cluster_centers = mbk.cluster_centers_[order]\n\nk_means_labels = pairwise_distances_argmin(X, k_means_cluster_centers)\nmbk_means_labels = pairwise_distances_argmin(X, mbk_means_cluster_centers)\n\n# KMeans\nax = fig.add_subplot(1, 3, 1)\nfor k, col in zip(range(n_clusters), colors):\n my_members = k_means_labels == k\n cluster_center = k_means_cluster_centers[k]\n ax.plot(X[my_members, 0], X[my_members, 1], 'w',\n markerfacecolor=col, marker='.')\n ax.plot(cluster_center[0], cluster_center[1], 'o', markerfacecolor=col,\n markeredgecolor='k', markersize=6)\nax.set_title('KMeans')\nax.set_xticks(())\nax.set_yticks(())\nplt.text(-3.5, 1.8, 'train time: %.2fs\\ninertia: %f' % (\n t_batch, k_means.inertia_))\n\n# MiniBatchKMeans\nax = fig.add_subplot(1, 3, 2)\nfor k, col in zip(range(n_clusters), colors):\n my_members = mbk_means_labels == k\n cluster_center = mbk_means_cluster_centers[k]\n ax.plot(X[my_members, 0], X[my_members, 1], 'w',\n markerfacecolor=col, marker='.')\n ax.plot(cluster_center[0], cluster_center[1], 'o', markerfacecolor=col,\n markeredgecolor='k', markersize=6)\nax.set_title('MiniBatchKMeans')\nax.set_xticks(())\nax.set_yticks(())\nplt.text(-3.5, 1.8, 'train time: %.2fs\\ninertia: %f' %\n (t_mini_batch, mbk.inertia_))\n\n# Initialise the different array to all False\ndifferent = (mbk_means_labels == 4)\nax = fig.add_subplot(1, 3, 3)\n\nfor k in range(n_clusters):\n different += ((k_means_labels == k) != (mbk_means_labels == k))\n\nidentic = np.logical_not(different)\nax.plot(X[identic, 0], X[identic, 1], 'w',\n markerfacecolor='#bbbbbb', marker='.')\nax.plot(X[different, 0], X[different, 1], 'w',\n markerfacecolor='m', marker='.')\nax.set_title('Difference')\nax.set_xticks(())\nax.set_yticks(())\n\nplt.show()"
3030
]
3131
}
3232
],
Binary file not shown.

dev/_downloads/scikit-learn-docs.pdf

-10.4 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes
-120 Bytes
-120 Bytes
-82 Bytes
-560 Bytes
-560 Bytes
179 Bytes
-155 Bytes
-155 Bytes
-193 Bytes
301 Bytes
301 Bytes
-192 Bytes
-85 Bytes
12 Bytes
328 Bytes
257 Bytes
-2.54 KB
-2.54 KB
-455 Bytes
318 Bytes
318 Bytes
71 Bytes
71 Bytes
-89 Bytes
-89 Bytes
-45 Bytes
-45 Bytes
-146 Bytes
-146 Bytes
-58 Bytes
-58 Bytes
-177 Bytes
121 Bytes
-156 Bytes
-156 Bytes
-82 Bytes
-326 Bytes
-361 Bytes
-361 Bytes
-253 Bytes
-361 Bytes
-144 Bytes
-144 Bytes
-186 Bytes
-19 Bytes

dev/_sources/auto_examples/applications/plot_face_recognition.rst.txt

Lines changed: 15 additions & 15 deletions

dev/_sources/auto_examples/applications/plot_model_complexity_influence.rst.txt

Lines changed: 15 additions & 15 deletions

0 commit comments

Comments
 (0)