Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to perform $k$-Nearest Neighbor Search in multidimensional space, but not using for example $L_2$-distance. I want the user to specify some "similar"-pairs examples and then perform a search using this information.

What algorithm can I use for this?

share|improve this question
Can you be a bit more specific regarding what type of metric you want to use? – Pedro Nov 20 '12 at 14:11
@Pedro I don't know what metric I want, but I think it must depend on data. I don't know what "similar" mean, but I have pairs(examples) which are similar and I want to extract similarity metric from this data and then perform K-Nearest Neighbor Search. Maybe I can use metric like here slide 10 – mrgloom Nov 21 '12 at 14:05
@mrgloom So do you want to train a classifier and then apply that to determine neighbors? – Deathbreath Jan 7 '13 at 14:24

This functionality is implemented in the libAGF library. Check here: To get an overview (the webpage is not very informative), download the library and check for the agf_paper in doc directory.

share|improve this answer
Is that paper also available separately, so that one doesn't have to download the library? – Arnold Neumaier Nov 21 '12 at 10:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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