1
$\begingroup$

I have a multi-class classification problem, in which I'm using caret package k nearest neighbour classifier, (4 classes), which means that an odd number for k won't prevent classification ties.

So how does caret resolve ties in the k nearest neighbour classification?

$\endgroup$

closed as off-topic by Michael Chernick, Peter Flom Jun 10 at 13:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Michael Chernick, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ In these cases, reading the relevant relevant help files is often the fastest solution. Also, I am not sure that caret is doing the nearest neighbor match. It is usually a wrapper around functions in other packages. $\endgroup$ – lmo Jun 9 at 22:00
0
$\begingroup$

It appears that manual page doesn't state it explicitly. But, a close inspection of the source code reveals that it chooses the class randomly, via sample method in R. I've managed to reproduce the iris dataset example in the above linked man-page using 2 neighbours. It results in different class assignments under different runs (see the 75-th test example).

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.