From 1afa116d61babd400d68e26a5e349153bfafe6b5 Mon Sep 17 00:00:00 2001 From: Brian Wright Date: Sun, 30 Nov 2025 20:02:16 +0000 Subject: [PATCH] update comments --- .../notebooks/Final_Project_Notebook.ipynb | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ds1001_final/notebooks/Final_Project_Notebook.ipynb b/ds1001_final/notebooks/Final_Project_Notebook.ipynb index 0069340..f4688e7 100644 --- a/ds1001_final/notebooks/Final_Project_Notebook.ipynb +++ b/ds1001_final/notebooks/Final_Project_Notebook.ipynb @@ -68,7 +68,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Activate the finalproject environment\n", + "# Activate the finalproj environment\n", "!source ds1001_final/ds1001_final/finalproj/bin/activate" ] }, @@ -96,6 +96,14 @@ "# ensure all packages are installed)" ] }, + { + "cell_type": "markdown", + "id": "aae8b41a", + "metadata": {}, + "source": [ + "### Check !pip list again to confirm installations" + ] + }, { "cell_type": "code", "execution_count": null, @@ -311,15 +319,11 @@ "cell_type": "code", "execution_count": null, "id": "d6f008fe", - "metadata": { - "vscode": { - "languageId": "markdown" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Divide the dataset into features and target\n", - "target = \"xx\"['TargetVariable'] # Replace 'TargetVariable' with your actual target column name\n", + "target = \"xx\"['TargetVariable'] # Replace 'TargetVariable' with your actual target column name and \"xx\" with your dataframe name\n", "features = \"xx\".drop(columns=[target])\n" ] }, @@ -344,10 +348,11 @@ "\n", "accuracy_results = {}\n", "\n", - "for k in range(x, x): # Replace x with your desired range values\n", + "for k in range(x, x): # Replace x with your desired range values, explain what is happening in this loop\n", " knn_model = KNeighborsClassifier(n_neighbors=k)\n", " knn_model.fit(X_train, y_train)\n", - " accuracy = knn_model.score(X_test, y_test)" + " accuracy = knn_model.score(X_test, y_test)\n", + " accuracy_results[k] = accuracy" ] }, { @@ -376,7 +381,7 @@ "outputs": [], "source": [ "# using the hyperparameter k that gave the best accuracy, rerun the model and generate \n", - "# predictions on the test set.\n", + "# predictions on the test set. Explain why you choose this k value.\n", "best_k = 'xx' # Replace 'xx' with the best k value found\n", "knn_model = KNeighborsClassifier(n_neighbors=best_k)\n", "knn_model.fit(X_train, y_train)\n", @@ -398,7 +403,8 @@ "metadata": {}, "outputs": [], "source": [ - "# create a confusion matrix for your model's predictions.\n", + "# create a confusion matrix for your model's predictions. \n", + "# What does the confusion matrix tell you about your model's performance?\n", "cm = confusion_matrix(y_test, y_pred)\n", "disp = ConfusionMatrixDisplay(confusion_matrix=cm)\n", "disp.plot()\n",