I am not too sure how to use K-NN to calculate the error on this data set (as shown below).

Any help would be appreciated.

enter image description here

Source: https://i.sstatic.net/w14KT.jpg

  • 1
    $\begingroup$ @nsc10 Where exactly did you get stuck ? One can surely write down a complete solution, but it would be more helpful (especially for you regarding the learning experience) if you would tell use what you have already did. For example, do you already know how k-NN and leave-one-out-crossvalidation works ? $\endgroup$
    – steffen
    Commented Apr 11, 2013 at 18:50
  • $\begingroup$ @steffen Thanks for the reply, I know how k-NN works but am not competent with leave-one-out-cross validation. I am not too sure how to start this question $\endgroup$
    – nsc010
    Commented Apr 11, 2013 at 18:59

1 Answer 1


You only need to do this loop:

Take one of the points and put it aside. Train the kNN (training is just copying the points)

Now take that point and evaluate the kNN output: take a look at the k-closests points. And assign the label accordingly. If it does not match the label of the point, then it is an error, otherwise not.

Make sure you understand how kNN assigns a label to a sample.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.