Open
Conversation
anjali-deshpande-hub
approved these changes
Nov 26, 2025
anjali-deshpande-hub
left a comment
There was a problem hiding this comment.
Well done.
In your PR comments, you mentioned that you couldn't run your code in VSCode because of installation issue. If you are still facing this issue, please message Daniel and he can help you set it up so its easier for you in future modules and assignments.
Some review comments:
- Instead of hardcoding the best value of neighbor found. You can do -
best_n_neighbors = wine_tune_grid.best_params_['n_neighbors']
knn = KNeighborsClassifier(n_neighbors=best_n_neighbors)
- If you do:
X_train, X_test, y_train, y_test = train_test_split(predictors_standardized, wine_df['class'], test_size=0.25)
you can use X_train and X_test instead of iloc[:, :-1] again and its more readable.
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)
I added my code and answers to the appropriate cells in the Assignment_1 jupyter notebook. This included calculated the columns and rows of the wine dataframe, standardizing (centring and scaling) the predictor variables, using 10-fold cross-validation to select the best value for nearest neighbours, and then running a K-Nearest Neighbours algorithm on a test set.
What did you learn from the changes you have made?
I learned how to run KNN in python. I had previous experience doing this in R. I also learned more about SciKit Learn functions such as the accuracy score and splitting training and testing sets by proportions.
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
I was testing out how I should index the columns for the the predictor variables given that it's a larger number (13 predictors) than the example used in the class. I ended up just using the same
.iloc[ : , :-1]method that was already given in the code.Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
For some reason, the packages would not be installed through VS Code even when the virtual environment was created as per the SETUP.md instructions. This greatly limited my ability to run and test code straight from the notebook. To overcome this, I uploaded a copy of the assignment notebook to my JupyterHub account (through UofT) and drafted my answers there. I was able to re-run the code with no issues on JupyterHub. Then, I opened the original assignment file in VS Code and copied my answers over.
How were these changes tested?
By re-running the cells after each new line of code.
A reference to a related issue in your repository (if applicable)
Checklist