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?

解决方案

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.

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.)

python增量更新数据,Python中的增量最近邻算法相关推荐

  1. python sqlite3更新数据,python sqlite3-使用f字符串更新数据库函数

    我有自己的个人数据库,这是为了好玩(所以我不把SQL注入作为我自己的私人数据库),我正在尝试更改我创建的使用字符串格式(.format())和占位符(?,然后使用f字符串.我遇到了一个问题,在我将sq ...

  2. python分析人口出生率代码_国家统计局居然也能用的上Python?人口数据Python脚本了解一下?...

    原标题:国家统计局居然也能用的上Python?人口数据Python脚本了解一下? 通过采集国家统计局"国家数据"网站中提供的中国历年人口数据,并对数据进行可视化的探索,发现了一些有 ...

  3. python增量更新数据_Python标准库——加密

    增量更新 散列计算器的update()方法可以反复调用.每次调用时,都会根据提供的附加文本更新摘要.增量更新比将整个文件读入内存更高效,而且能生成相同的效果. 新建hashlib_update.py文 ...

  4. solr4 mysql自动更新_solr7.4 定时增量更新数据-Go语言中文社区

    准备 centos7 下solr7.4.0 配置mysql 数据源 可参考: https://blog.csdn.net/guyan0319/article/details/81203184 配置da ...

  5. python引用大数据,Python 3 UDF

    Python 2官方即将停止维护,MaxCompute支持Python 3.MaxCompute使用的Python 3版本为CPython-3.7.3.本文为您介绍如何通过MaxCompute Pyt ...

  6. python处理表格数据-Python数据处理(二):处理 Excel 数据

    在本章和下一章里,我们将研究两种文件类型实例:Excel 文件和 PDF,并给出几条一般性说明,在遇到其他文件类型时可以参考. 处理 Excel 比上章讲的处理 CSV.JSON.XML 文件要难多了 ...

  7. python整理excel数据-Python 自动整理 Excel 表格

    相信有不少朋友日常工作会用到 Excel 处理各式表格文件,更有甚者可能要花大把时间来做繁琐耗时的表格整理工作.最近有朋友问可否编程来减轻表格整理工作量,今儿我们就通过实例来实现 Python 对表格 ...

  8. python导入excel数据-Python数据处理之导入导出excel数据

    欢迎点击上方"AntDream"关注我 .Python的一大应用就是数据分析了,而数据分析中,经常碰到需要处理Excel数据的情况.这里做一个Python处理Excel数据的总结, ...

  9. 用python玩转数据Python便捷数据获取与预处理 quiz

    用python玩转数据第四章测试 Python便捷数据获取与预处理 quiz 1.pandas模块中的read_csv()函数在日常使用较多,它除了可以读取csv格式的文件并将结果转换成一个DataF ...

最新文章

  1. 集成学习+ensemble learning
  2. 详细解剖大型H5单页面应用的核心技术点
  3. 使用android ProgressBar和Toast生成一个界面
  4. 2048. 下一个更大的数值平衡数
  5. java http请求_如何设置Fiddler来拦截Java代码发送HTTP请求,进行各种问题排查
  6. Linux内核驱动如何编写?我们先从字符驱动入门开始
  7. Python学习笔记:文件读/写方法汇总
  8. 一蔚来ES8汽车疑似失控 将地下车库墙撞穿
  9. 网络中的哪些事儿(三)之我眼中的三层交换机
  10. CardLayout使用
  11. python数据分析之(4)读写数据文件CSV,EXCEL等
  12. Recovery dropped Procedure
  13. GBase 8atmp 目录权限改变导致加载失败
  14. Ionic3/4中如何上传图片(拍照/图片选择)
  15. 石墨文档代码学习笔记分享
  16. Python函数里的爱情故事
  17. 今年春季清华大学雨课堂主讲嘉宾邹晓辉讲授了融智学系列公益课:
  18. SSH登录时“no matching host key type found. Their offer: ssh-rsa,ssh-dss“的错误解决方法
  19. 什么是姿态角(Euler角)pitch yaw roll
  20. 后端线上问题排查常用命令;关键时候能救命,建议收藏!

热门文章

  1. 通过单步调试的方式学习 Angular 中 TView 和 LView 的概念
  2. 介绍一个使用 cl_abap_corresponding 进行两个内表不同名称字段赋值的快捷方法
  3. 如何确认客户使用的Spartacus库文件是未经修改过的原始版本
  4. WordPress Kyma插件里Connect和disconnect按钮的动态显示逻辑
  5. 如何在SAP Cloud for Customer页面嵌入自定义UI
  6. SAP Fiori Elements Service Order edit - why no http request sent
  7. 运行在Docker里的SpringBoot应用,如何查看记录在文件系统的日志
  8. SAP Hybris Commerce帮助文档的结构
  9. header response in Genil
  10. SAP Fiori RouteMatched and getById