KNN classifier determining best K- value

2 次查看(过去 30 天)
Hello, I am working on KNN classifier and I have to comment on the best K value on over all output. But I cant find what is the best K value as the outputs for the data sets are different from one another. Is there any generalised best K value for KNN classifier for a data set with N features or it varies with each dataset. Thankyou.

回答(1 个)

Image Analyst
Image Analyst 2015-7-26
You should have a training set that you have "ground truth" for - known values. Try different K and see which K gives you the highest accuracy. Sure, the best K might be different for a different data set, but you'll never know because you don't know what the right answers are for those data - if you did you would have used them in the training because it's best to use as much training data as you can if you want to find the best K. If you use a small portion of your data to train, then how much confidence can you have that the K you find will be the best? So you use all your know data in training. Anyway, that's how I see it, but I'm not a Ph.D. Statistician so I could be wrong but I still think that to know what's "best" you have to know what it got right and what it got wrong.
  1 个评论
Matpar
Matpar 2019-9-27
编辑:Matpar 2019-9-27
HI Image Analyst,
Can KNN be applied for classifying pixels on a single image? Can you guide me please implementing these steps in MATLAB, I am googling and it still seems challenging,
Thank you for responding!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by