How to interpret predict parameters obtained from KNN?
I have trained KNN to recognise obj A as 1
When I am doinh knn->findKnearest(data,m,response,neighbor,dist);
I get response as 0; Then neighbor [1,0,...] dist[0,0.23333]
What does this mean? Do I have to use euclidean distance to do matching?
Please, use the documentation: http://docs.opencv.org/master/dd/de1/...
I have alreday read that. What I am asking is that is class 1 dist is 0 why am i getting response as class 0 instead of class 1
That wasn't what you asked, you just threw some numbers and asked what they meant... Anyway, the docs say "In case of classification, the class is determined by voting" (I guess you're doing classification). Take a look at this tutorial to get a better grasp of knn, and why having a distance zero to one class does not necessarily imply to have a sample belonging to such class.
I have not thrown some random numbers. I am working with KNN and I got this problem that is why I am asking. I do not understand how to get the correct label. Thanks for the link. It is the sample which which I have trained the data so knn should output label 1
Are you using such very same sample code? If so, giving that both training and test data are randomly generated, I don't see why you should expect same results at all. And about the other issue, just saying that you should post clear detailed questions in the future.
if you get mispredictions here: