update comments

This commit is contained in:
Brian Wright 2025-11-30 20:02:16 +00:00
parent f6069f4256
commit 1afa116d61

View file

@ -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",