Question



How select the sequence parameter to use in a loop while trying to determine the optimal K for a KNN model

ICG 15: Question 2
The goal is to make predictions using a KNN model for all test instances.
Step 1: Determine the optimal k (1,20, 40,..., 2001) using train, ytrain, val and yval

The ICG solution shows the first line of code in the loop as:
for (k in seq(1, 1201, 20 )){}

Why is the sequence set to end at 1201 instead of 2001? Why would the code not be this instead?:
for (k in seq(1, 2001, 20 )) {}

Thank you.





Answers and follow-up questions





Answer or follow-up question 1

Dear student,

Thank you for pointing out this typo.

Michel Ballings



Sign in to be able to add an answer or mark this question as resolved.