Skip to content

Commit a75ee78

Browse files
committed
Pushing the docs for revision for branch: master, commit bd4e00b1eb5c1fee4603a248be23ff72be9d855c
1 parent 51d6aca commit a75ee78

File tree

1,422 files changed

+3532
-3539
lines changed

Some content is hidden

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

1,422 files changed

+3532
-3539
lines changed
-17 Bytes
Binary file not shown.
-33 Bytes
Binary file not shown.

dev/_downloads/plot_kmeans_digits.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"execution_count": null,
2525
"cell_type": "code",
2626
"source": [
27-
"print(__doc__)\n\nfrom time import time\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn import metrics\nfrom sklearn.cluster import KMeans\nfrom sklearn.datasets import load_digits\nfrom sklearn.decomposition import PCA\nfrom sklearn.preprocessing import scale\n\nnp.random.seed(42)\n\ndigits = load_digits()\ndata = scale(digits.data)\n\nn_samples, n_features = data.shape\nn_digits = len(np.unique(digits.target))\nlabels = digits.target\n\nsample_size = 300\n\nprint(\"n_digits: %d, \\t n_samples %d, \\t n_features %d\"\n % (n_digits, n_samples, n_features))\n\n\nprint(79 * '_')\nprint('% 9s' % 'init'\n ' time inertia homo compl v-meas ARI AMI silhouette')\n\n\ndef bench_k_means(estimator, name, data):\n t0 = time()\n estimator.fit(data)\n print('% 9s %.2fs %i %.3f %.3f %.3f %.3f %.3f %.3f'\n % (name, (time() - t0), estimator.inertia_,\n metrics.homogeneity_score(labels, estimator.labels_),\n metrics.completeness_score(labels, estimator.labels_),\n metrics.v_measure_score(labels, estimator.labels_),\n metrics.adjusted_rand_score(labels, estimator.labels_),\n metrics.adjusted_mutual_info_score(labels, estimator.labels_),\n metrics.silhouette_score(data, estimator.labels_,\n metric='euclidean',\n sample_size=sample_size)))\n\nbench_k_means(KMeans(init='k-means++', n_clusters=n_digits, n_init=10),\n name=\"k-means++\", data=data)\n\nbench_k_means(KMeans(init='random', n_clusters=n_digits, n_init=10),\n name=\"random\", data=data)\n\n# in this case the seeding of the centers is deterministic, hence we run the\n# kmeans algorithm only once with n_init=1\npca = PCA(n_components=n_digits).fit(data)\nbench_k_means(KMeans(init=pca.components_, n_clusters=n_digits, n_init=1),\n name=\"PCA-based\",\n data=data)\nprint(79 * '_')"
27+
"print(__doc__)\n\nfrom time import time\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn import metrics\nfrom sklearn.cluster import KMeans\nfrom sklearn.datasets import load_digits\nfrom sklearn.decomposition import PCA\nfrom sklearn.preprocessing import scale\n\nnp.random.seed(42)\n\ndigits = load_digits()\ndata = scale(digits.data)\n\nn_samples, n_features = data.shape\nn_digits = len(np.unique(digits.target))\nlabels = digits.target\n\nsample_size = 300\n\nprint(\"n_digits: %d, \\t n_samples %d, \\t n_features %d\"\n % (n_digits, n_samples, n_features))\n\n\nprint(82 * '_')\nprint('init\\t\\ttime\\tinertia\\thomo\\tcompl\\tv-meas\\tARI\\tAMI\\tsilhouette')\n\n\ndef bench_k_means(estimator, name, data):\n t0 = time()\n estimator.fit(data)\n print('%-9s\\t%.2fs\\t%i\\t%.3f\\t%.3f\\t%.3f\\t%.3f\\t%.3f\\t%.3f'\n % (name, (time() - t0), estimator.inertia_,\n metrics.homogeneity_score(labels, estimator.labels_),\n metrics.completeness_score(labels, estimator.labels_),\n metrics.v_measure_score(labels, estimator.labels_),\n metrics.adjusted_rand_score(labels, estimator.labels_),\n metrics.adjusted_mutual_info_score(labels, estimator.labels_),\n metrics.silhouette_score(data, estimator.labels_,\n metric='euclidean',\n sample_size=sample_size)))\n\nbench_k_means(KMeans(init='k-means++', n_clusters=n_digits, n_init=10),\n name=\"k-means++\", data=data)\n\nbench_k_means(KMeans(init='random', n_clusters=n_digits, n_init=10),\n name=\"random\", data=data)\n\n# in this case the seeding of the centers is deterministic, hence we run the\n# kmeans algorithm only once with n_init=1\npca = PCA(n_components=n_digits).fit(data)\nbench_k_means(KMeans(init=pca.components_, n_clusters=n_digits, n_init=1),\n name=\"PCA-based\",\n data=data)\nprint(82 * '_')"
2828
],
2929
"outputs": [],
3030
"metadata": {

dev/_downloads/plot_kmeans_digits.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@
5252
% (n_digits, n_samples, n_features))
5353

5454

55-
print(79 * '_')
56-
print('% 9s' % 'init'
57-
' time inertia homo compl v-meas ARI AMI silhouette')
55+
print(82 * '_')
56+
print('init\t\ttime\tinertia\thomo\tcompl\tv-meas\tARI\tAMI\tsilhouette')
5857

5958

6059
def bench_k_means(estimator, name, data):
6160
t0 = time()
6261
estimator.fit(data)
63-
print('% 9s %.2fs %i %.3f %.3f %.3f %.3f %.3f %.3f'
62+
print('%-9s\t%.2fs\t%i\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f'
6463
% (name, (time() - t0), estimator.inertia_,
6564
metrics.homogeneity_score(labels, estimator.labels_),
6665
metrics.completeness_score(labels, estimator.labels_),
@@ -83,7 +82,7 @@ def bench_k_means(estimator, name, data):
8382
bench_k_means(KMeans(init=pca.components_, n_clusters=n_digits, n_init=1),
8483
name="PCA-based",
8584
data=data)
86-
print(79 * '_')
85+
print(82 * '_')
8786

8887
###############################################################################
8988
# Visualize the results on PCA-reduced data
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)