taking Y of the nearest neighbors


How do you manually take Y of the nearest neighbors?

I see in the textbook that the training set has a dependent variable y = {0,1} but I am unsure of how to apply this to my 5 least
dissimilar instances.


Answers and follow-up questions

Answer or follow-up question 1

Dear student,

If you know the row indices of the nearest neighbors, you can simply use subsetting to retrieve the labels ,as in:


where Y are the labels and ind are the indices.

Michel Ballings

Sign in to be able to add an answer or mark this question as resolved.