Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2021/iii/paper-218/5/c/solution

For each , the call to knn.cv performs leave-one-out nearest-neighbour classification and the third line stores the fraction of omitted observations misclassified. Choose a minimizer of ls, then fit the nearest-neighbour classifier with that to the full data.

New to topics? Read the docs here!