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:
2025-12-13 23:38:17 +01:00
parent f89ff4a016
commit d5a6bfd339
50 changed files with 779 additions and 449 deletions

View File

@@ -238,7 +238,10 @@
"from sklearn.model_selection import train_test_split\n",
"\n",
"X_train, X_test, y_train, y_test = train_test_split(\n",
" X, y, test_size=0.33, random_state=42\n",
" X,\n",
" y,\n",
" test_size=0.33,\n",
" random_state=42,\n",
")"
]
},
@@ -702,10 +705,10 @@
"predictions2 = [knn_class_2(X_train, y_train, data, 3) for data in X_test]\n",
"\n",
"print(\n",
" f\"The accuracy rate of our classifier is {np.sum(predictions == y_test) / len(predictions) * 100}%\"\n",
" f\"The accuracy rate of our classifier is {np.sum(predictions == y_test) / len(predictions) * 100}%\",\n",
")\n",
"print(\n",
" f\"The accuracy rate of our classifier is {np.sum(predictions2 == y_test) / len(predictions2) * 100}%\"\n",
" f\"The accuracy rate of our classifier is {np.sum(predictions2 == y_test) / len(predictions2) * 100}%\",\n",
")"
]
},
@@ -1278,6 +1281,7 @@
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"from sklearn.neighbors import KNeighborsClassifier"
]
},
@@ -2094,7 +2098,10 @@
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(\n",
" X, y, test_size=0.33, random_state=42\n",
" X,\n",
" y,\n",
" test_size=0.33,\n",
" random_state=42,\n",
")"
]
},