1
$\begingroup$

I'm using euclidean distance for kNN. I have labeled data, I have took logarithm of some variables to make them look more like normaly distributed and scaled them all. And now I would like to multiply some variables by weights, then compute euclidean distance and train kNN. But how to find those weights ? My idea is to determine centers of classes this going to be set C, and then make optimization of kNN on set C by random search, I think that I can't do it on subset of training set, because it size would by to high or too small for accurate representation/sampling of dataset

Do you have any other ideas ? I don't think that changing parameters k and l going to have the same approach as mine or mayby does it ?

$\endgroup$
2
  • 1
    $\begingroup$ What variables would you like to multiply with what weights? kNN does not rely on class centers - please be clearer with what you want to achieve in your question. $\endgroup$
    – Andrew
    Commented May 7, 2012 at 8:23
  • $\begingroup$ @Qbik also please revise the last paragraph. What do you mean with the last sentence ? It does not make any sense currently $\endgroup$
    – steffen
    Commented May 7, 2012 at 9:19

2 Answers 2

1
$\begingroup$

Hastie and Tibshirani's paper on Discriminative Adaptive Nearest Neighbour Classification would be a good place to start.

A simple approach would be to choose the weights to minimise the leave-one-out error rate. However one of the advantages of kNN is that, being a relatively simple method, it is usually quite easy to avoid over-fitting (basically just need to choose k), and this advantage is easily lost if you try to tune the distance metric, so it may well make the performance of the model worse rather than better.

$\endgroup$
0
$\begingroup$

The "training" in a kNN algorithm is simply storing the training data along with their classes (kNN is a lazy learning algorithm - we identify the actual class the the object we try to classify belongs to only upon obtaining this object).

$\endgroup$
2
  • 1
    $\begingroup$ +1 for your comment to the OP's question. I suggest to make this reply a comment too... it does not address one of the OP's (still unclear) questions but may help clarify his/her intentions. $\endgroup$
    – steffen
    Commented May 7, 2012 at 9:17
  • $\begingroup$ The OP asked about training of kNN - in fact I was initially unsure whether I should post a reply or a comment with this info. I am starting to think that the OP might in fact want to cluster the data instead. Thanks for you suggestion @steffen I will move this to a comment shortly pending a (hopefully) edited question. $\endgroup$
    – Andrew
    Commented May 7, 2012 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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