Skip to content

Comments

asignment 1 submission#1

Open
AnthoniaAina wants to merge 6 commits intomainfrom
assignment-one
Open

asignment 1 submission#1
AnthoniaAina wants to merge 6 commits intomainfrom
assignment-one

Conversation

@AnthoniaAina
Copy link
Owner

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

Submitting Assignment 1 for LCR

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?

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

How were these changes tested?

I ran the code in visual studio

A reference to a related issue in your repository (if applicable)

Checklist

  • I can confirm that my changes are working as intended

Copy link

@anjali-deshpande-hub anjali-deshpande-hub left a comment

Choose a reason for hiding this comment

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

Question 1: (ii) 'class' is categorical variable. Therefore , it should not be standardized. Standardization only makes sense for numeric, continuous variables.

Question 2: (iv) You have to use standardized data (predictors_standardized) instead of actual data (wine_df) for generating the training and testing set. Please correct that.

Also. instead of using Wine_train, Wine_test = train_test_split(..., try using
X_train, X_test, y_train, y_test = train_test_split(...

That way, it will be easier for you to call subsequent function calls namely, fit and predict.

Question 4 has some runtime errors. Please feel free to get assistance from Learning support during work periods if you need help fixing the errors

@anjali-deshpande-hub
Copy link

A friendly reminder to complete the requested review changes for assignment 1. Thank you.

@anjali-deshpande-hub
Copy link

Anthonia, Some of the requested review changes have not been made.

  1. Answer to Question 1 (ii) is incorrect.
  2. Question 2 (iv): train_test_split is meant to split X and y together, so the correspondence between rows and labels is guaranteed. Correct usage is:
X = predictors_standardized
y = wine_df['class']

X_train, X_test, y_train, y_test = train_test_split(
    X, y, train_size=0.75, shuffle=True, random_state=123
)

GridSearchCV expects an unfitted estimator and will clone it internally. Giving it a previously fitted knn does not break, but is misleading. COrrect usage is:

knn = KNeighborsClassifier()  # no n_neighbors fixed
param_grid = {'n_neighbors': range(1, 51, 5)}

wine_tune_grid = GridSearchCV(
    estimator=knn,
    param_grid=param_grid,
    cv=10,
    refit=True
)
wine_tune_grid.fit(X_train, y_train)
  1. Question 4. Use the accuracy_score function to calculate single value with the best KNN model found.

Copy link

@anjali-deshpande-hub anjali-deshpande-hub left a comment

Choose a reason for hiding this comment

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

Please make the requested changes. Thank you.

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