mirror of
https://github.com/harivansh-afk/ds1001_final.git
synced 2026-04-15 08:03:43 +00:00
update comments
This commit is contained in:
parent
f6069f4256
commit
1afa116d61
1 changed files with 17 additions and 11 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue