Skip to content

Assignment_1 Completed#1

Open
nicosarian wants to merge 1 commit into
mainfrom
assignment_1
Open

Assignment_1 Completed#1
nicosarian wants to merge 1 commit into
mainfrom
assignment_1

Conversation

@nicosarian

Copy link
Copy Markdown
Owner

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

  • I can confirm that my changes are working as intended

@Shiraz-Latif Shiraz-Latif left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment is complete.
Well Done !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants