Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value of k in k nearest neighbor algorithm

I have 7 classes that needs to be classified and I have 10 features. Is there a optimal value for k that I need to use in this case or do I have to run the KNN for values of k between 1 and 10 (around 10) and determine the best value with the help of the algorithm itself?

like image 451
user574183 Avatar asked Jul 19 '12 20:07

user574183


1 Answers

In addition to the article I posted in the comments there is this one as well that suggests:

Choice of k is very critical – A small value of k means that noise will have a higher influence on the result. A large value make it computationally expensive and kinda defeats the basic philosophy behind KNN (that points that are near might have similar densities or classes ) .A simple approach to select k is set k = n^(1/2).

It's going to depend a lot on your individual cases, sometimes it is best to run through each possible value for k and decide for yourself.

like image 117
NominSim Avatar answered Oct 26 '22 10:10

NominSim