Search code examples
pythonmachine-learningscikit-learnknn

Furthest points of a point in kNN


In the documentation of kNN classifier, there is a method kneighbors, which returns k nearest neighbors. I am interested in how to return k furthest neighbors in such classifier elegantly?


Solution

  • Nope, there is no such capability.

    You need to remember that for performance, there would be a tree to get the closest neighbors. Trying to find the furthest means going through the full tree, basically computing all distance.

    So don't use kNN in that case, just compute distances and sort them.