Assignment_1 Completed#1
Open
nicosarian wants to merge 1 commit into
Open
Conversation
Shiraz-Latif
approved these changes
Apr 27, 2026
Shiraz-Latif
left a comment
There was a problem hiding this comment.
Assignment is complete.
Well Done !!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
Added code and written answers to assignment_1.ipynb to complete the KNN classification exercise on the Wine dataset. Changes include: data inspection code (rows, columns, dtypes, predictor count), written explanations for standardization and data splitting decisions, a train/test split using train_test_split, a grid search over n_neighbors (1–50) using 10-fold cross-validation with GridSearchCV, and final model evaluation using accuracy_score on the test set.
What did you learn from the changes you have made?
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
I learned how sensitive KNN is to feature scaling — standardizing predictors is essential because the algorithm relies on distance calculations. I also learned how GridSearchCV automates hyperparameter tuning by systematically evaluating each candidate value of n_neighbors across cross-validation folds, which is more reliable than manually picking a value.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
Instead of GridSearchCV, I considered using cross_validate in a manual loop over values of n_neighbors and tracking the best mean accuracy myself. GridSearchCV achieves the same result more cleanly and is the preferred approach. I also considered using KFold explicitly to set up the cross-validation, but since GridSearchCV accepts a cv integer directly, that extra step was unnecessary.
How were these changes tested?
The main point of care was ensuring the train/test split used the same random_state as the np.random.seed call, so that results are fully reproducible. I also made sure to fit the scaler only on the training predictors (via fit_transform before splitting) to avoid data leakage from the test set into the standardization step.
A reference to a related issue in your repository (if applicable)
The notebook was run end-to-end to confirm that all cells execute without errors, that the grid search returns a valid best n_neighbors, and that accuracy_score produces a value between 0 and 1 on the held-out test set.
Checklist