Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3597590
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:08:17+00:00 2026-05-18T20:08:17+00:00

Is anyone aware of a nearest neighbor algorithm implemented in Python that can be

  • 0

Is anyone aware of a nearest neighbor algorithm implemented in Python that can be updated incrementally? All the ones I’ve found, such as this one, appear to be batch processes. Is it possible to implement an incremental NN algorithm?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:08:17+00:00Added an answer on May 18, 2026 at 8:08 pm

    I think the problem with incremental construction of a KD-tree or KNN-tree is, as you’ve alluded to in a comment, that the tree will eventually become unbalanced and you can’t do simple tree rotation to fix balance problems and keep consistency. At the minimum, the re-balancing task is not trivial and one would definitely not want to do it at each insertion. Often, one will choose to build a tree with a batch method, insert a bunch of new points and allow the tree to become unbalanced up to a point, and then re-balance it.

    A very similar thing to do is to build the data structure in batch for M points, use it for M’ points, and then re-build the data structure in batch with M+M’ points. Since re-balancing is not normal, fast algorithm we are familiar with for trees, rebuilding is not necessarily slow in comparison and in some cases can be faster (depending on how the sequence of the points entering your incremental algorithm).

    That being said, the amount of code you write, debugging difficulty, and the ease of others’ understanding of your code can be significantly smaller if you take the rebuild approach. If you do so, you can use a batch method and keep an external list of points not yet inserted into the tree. A brute force approach can be used to ensure none of these is closer than the ones in the tree.

    Some links to Python implementations/discussions are below, but I haven’t found any that explicitly claim to be incremental. Good luck.

    http://www.scipy.org/Cookbook/KDTree

    http://cgi.di.uoa.gr/~compgeom/pycgalvisual/kdppython.shtml

    http://sites.google.com/site/mikescoderama/Home/kd-tree-knn

    http://en.wikipedia.org/wiki/Kd-tree

    Note: My comments here apply to high-dimensional spaces. If you’re working in 2D or 3D, what I’ve said may not be appropriate. (If you working in very high dimensional spaces, use brute force or approximate nearest neighbor.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is anyone aware of a nearest neighbor algorithm implemented in Python that can be
Is anyone aware of a custom layout component that can take css to position
Is anyone aware of any implemented algorithms/programs that could fall under the category of
Is anyone aware of a package that implements a supervised learning algorithm for the
Is anyone aware of a script/class (preferably in PHP) that would parse a given
Is anyone aware of any method (or external plugin) that would allow for nested
Anyone aware of a CCK module that adds a text field that's just a
Is anyone aware of a Visual Studio 2010 Add-In that will automatically allow you
Is anyone aware of a turn-based based strategy game engine that is open source?
Is anyone aware of an eclipse plugin that updates the tooltip on hover over

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.