-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from sklearn import datasets\n", | ||
"from sklearn.cluster import KMeans\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"digits = datasets.load_digits()\n", | ||
"kmeans = KMeans(n_clusters=10, random_state=0).fit(digits.data)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAxsAAAFBCAYAAAAfVLJxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/NK7nSAAAACXBIWXMAAA9hAAAPYQGoP6dpAAASXUlEQVR4nO3Z36/XBf0H8HM4HzhwOBzOGTBoHDwoOoxcP7aKcCO0poPSxYURWlizC2atttJI60LszvVjc6VtyA1z64KFGwVpplso9mNKzma0YYm0EwkLD3gOcAgOn/6B73eDPc/rsE+fx+Oa1/PzFM55n/P03dlsNpsdAAAAk2zalS4AAAD8bzI2AACAEsYGAABQwtgAAABKGBsAAEAJYwMAAChhbAAAACWMDQAAoETjShe4HOfPn48zHnnkkThj165dccZTTz0V3Q8NDcUdpk1rr6155syZ6H7Lli1xhyeeeCLO6OnpiTMeeOCB6P7rX/963GHWrFlxRqt55513ovvNmzfHHV566aU4Y2xsLM5YvHhxdP/9738/7n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AEo2p/LBTp05F9/fee2/cYWJiIs64cOFCnLF58+bo/rnnnos7DAwMxBmtpNlsRveHDx+OO2zdujXOePnll+OMwcHB6H5kZCTukP57tKLR0dHo/umnn447DA8PxxmT8ezYvXt3dH/zzTfHHRYvXhxntJI9e/ZE9y+88ELcYenSpXHGs88+G2esX78+ul+1alXcod2kz/xt27bFHX7/+9/HGRs2bIgzenp64oxW4s0GAABQwtgAAABKGBsAAEAJYwMAAChhbAAAACWMDQAAoISxAQAAlDA2AACAEsYGAABQwtgAAABKGBsAAEAJYwMAAChhbAAAACWMDQAAoISxAQAAlGhM5Ye98sor0f3w8HDcYceOHXHGqlWr4oxPf/rT0f2f//znuMOaNWvijFaSfv1873vfizs888wzccZVV10VZ4yOjkb3CxcujDt0dXXFGa3m3Llz0f3FixfjDoODg3HG+Ph4nDFz5szovqenJ+7Qbnp7e6P7L3/5y3GHZcuWxRmPPfZYnHH+/Pk4g8szNjYW3f/sZz+LO3zuc5+LM+688844Y86cOXFGK/FmAwAAKGFsAAAAJYwNAACghLEBAACUMDYAAIASxgYAAFDC2AAAAEoYGwAAQAljAwAAKGFsAAAAJYwNAACghLEBAACUMDYAAIASxgYAAFDC2AAAAEoYGwAAQInGVH7Y8PBwdD84OBh3uPHGG+OMpUuXxhkrV66M7l9++eW4w5o1a+KMVvLGG29E9/v27Ys79Pf3xxnHjh2LM86dOxfdv+c974k7TJvWfv+vY/r06dH9vHnz4g7p90FHR0fHxMREnPHwww9H9319fXGHdpM+84eGhuIOe/fujTPS51dHR0fHwMBAnMHl+de//hXd//vf/447LFy4MM7405/+FGdcffXV0f1kfC92dnbGGZeq/X7aAwAAU8LYAAAAShgbAABACWMDAAAoYWwAAAAljA0AAKCEsQEAAJQwNgAAgBLGBgAAUMLYAAAAShgbAABACWMDAAAoYWwAAAAljA0AAKCEsQEAAJQwNgAAgBKNqfywM2fORPfz58+POyxYsCDOaDTyv7bp06dH92NjY3GHdjM0NBTd33PPPXGHc+fOxRm7du2KM06ePBn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Nxh3aTPsNmz54ddxgdHY0zhoeH44z0WXzs2LG4w+HDh+OMefPmxRlTZdq07P9vP/7443GHe+65J87YtGlTnLF06dLo/tFHH407zJw5M864VN5sAAAAJYwNAACghLEBAACUMDYAAIASxgYAAFDC2AAAAEoYGwAAQAljAwAAKGFsAAAAJYwNAACghLEBAACUMDYAAIASxgYAAFDC2AAAAEoYGwAAQAljAwAAKNHZbDabV7oEAADwv8ebDQAAoISxAQAAlDA2AACAEsYGAABQwtgAAABKGBsAAEAJYwMAAChhbAAAACWMDQAAoMR/AWxq5L4YBqDoAAAAAElFTkSuQmCC", | ||
"text/plain": [ | ||
"<Figure size 1000x400 with 10 Axes>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"fig, axes = plt.subplots(2, 5, figsize=(10, 4))\n", | ||
"for i, c in enumerate(kmeans.cluster_centers_):\n", | ||
" axes[i // 5 , i % 5].imshow(c.reshape(8, 8), cmap=plt.cm.binary)\n", | ||
" axes[i // 5, i % 5].axis('off')\n", | ||
"# for c in range(10):\n", | ||
"# axes[1, c].imshow(digits.data[kmeans.labels_ == c][0].reshape(8, 8), cmap=plt.cm.binary)\n", | ||
"# axes[1, c].axis('off')\n", | ||
"plt.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.2" | ||
}, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |