KNN Quiz doubts

1,) How can we use cross validation for getting optimal k in knn algorithm ?
2.)how can we use knn for regression algorithms ?
3.)how does the boundary becomes smother when you increase the value of k , like in classification what do you mean by a smother boundary ?

Hello @anshushahi98,

  1. Split the training data into validation and training set. Keep 80% in training and 20% in testing. Using the 80% data, predict target values for the remaining 20% data with different k values. Now the k for which you have highest validation accuracy is your optimal k.

  2. For classification, we do voting across the k nearest neighbours and predict the class with the highest vote. In regression, we take the mean of the k nearest neighbour and predict that as the target value of the test instance.

  3. This link here can help you regarding the smoother boundary question of yours.

Happy Learning :slight_smile:
Thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.