mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-02-04 15:32:10 +01:00
Refactor code for improved readability and consistency across multiple Jupyter notebooks
- Added missing commas in various print statements and function calls for better syntax. - Reformatted code to enhance clarity, including breaking long lines and aligning parameters. - Updated function signatures to use float type for sigma parameters instead of int for better precision. - Cleaned up comments and documentation strings for clarity and consistency. - Ensured consistent formatting in plotting functions and data handling.
This commit is contained in:
@@ -543,7 +543,12 @@
|
||||
"plt.plot(X[:, 0], X[:, 1], \".b\", alpha=0.2)\n",
|
||||
"for center in kmeans1.cluster_centers_:\n",
|
||||
" plt.plot(\n",
|
||||
" center[0], center[1], \".\", color=\"red\", markersize=10, label=\"Cluster center\"\n",
|
||||
" center[0],\n",
|
||||
" center[1],\n",
|
||||
" \".\",\n",
|
||||
" color=\"red\",\n",
|
||||
" markersize=10,\n",
|
||||
" label=\"Cluster center\",\n",
|
||||
" )\n",
|
||||
"plt.legend()\n",
|
||||
"plt.show()"
|
||||
@@ -623,7 +628,12 @@
|
||||
"\n",
|
||||
"for center in kmeans1.cluster_centers_:\n",
|
||||
" plt.plot(\n",
|
||||
" center[0], center[1], \".\", color=\"red\", markersize=10, label=\"Cluster center\"\n",
|
||||
" center[0],\n",
|
||||
" center[1],\n",
|
||||
" \".\",\n",
|
||||
" color=\"red\",\n",
|
||||
" markersize=10,\n",
|
||||
" label=\"Cluster center\",\n",
|
||||
" )\n",
|
||||
"plt.legend()\n",
|
||||
"plt.show()"
|
||||
@@ -1529,9 +1539,10 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import tensorflow as tf\n",
|
||||
"from scipy.stats import mode\n",
|
||||
"\n",
|
||||
"import tensorflow as tf\n",
|
||||
"\n",
|
||||
"mnist = tf.keras.datasets.mnist\n",
|
||||
"(X_train, y_train), (X_test, y_test) = mnist.load_data()\n",
|
||||
"\n",
|
||||
@@ -1543,7 +1554,7 @@
|
||||
"\n",
|
||||
"def map_clusters_to_labels(clusters, true_labels):\n",
|
||||
" return np.array(\n",
|
||||
" [mode(true_labels[clusters == i], keepdims=True).mode[0] for i in range(10)]\n",
|
||||
" [mode(true_labels[clusters == i], keepdims=True).mode[0] for i in range(10)],\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"\n",
|
||||
|
||||
Reference in New Issue
Block a user