Question

(10) (6 points) Based on the training data, implement 5-fold cross-validation (CV)

to select the best KNN model with the smallest CV error from different KNN

models under different K values, such as K = 200, 180, 160, 140, 120, 100, 80,

60, 40, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2 and 1. What is the optiaml K* for the selected

model? Based on the selected model, compute the confusion matrices and the

mis-classification error rates for both the training data and test data, respectively.

(Hint: please refer to sample code "cv-knn.R" in "Lecture Videos" sub-folder of

CANVAS Files and certain level of customization is needed. Set your random seed

as 2023 when you (i) split training data into 5 folds, and (ii) make predictions

using KNN models)

Question image 1