kd tree python 搜索
来源:互联网 发布:翻译机 知乎 编辑:程序博客网 时间:2024/05/21 05:24
海量数据最近邻查找可以用kd tree
目前理解,kd tree需要的数据维度相同,否则会出问题
kd tree实现:https://github.com/stefankoegl/kdtree
下面是测试代码:
import kdtree# Create an empty tree by specifying the number of# dimensions its points will haveemptyTree = kdtree.create(dimensions=3)# A kd-tree can contain different kinds of points, for example tuplespoint1 = (2, 3, 4)point2 = [4, 5, 6]import collectionsPoint = collections.namedtuple('Point', 'x y z')point3 = Point(5, 3, 2)tree = kdtree.create([point1, point2, point3])# Each (sub)tree is represented by its root nodetree.add((5, 4, 3))tree = tree.remove((5, 4, 3))print(list(tree.inorder()))# [<KDNode - (2, 3, 4)>, <KDNode - [4, 5, 6]>, <KDNode - Point(x=5, y=3, z=2)>]## # Retrieving the Tree in level orderprint(list(kdtree.level_order(tree)))# [<KDNode - [4, 5, 6]>, <KDNode - (2, 3, 4)>, <KDNode - Point(x=5, y=3, z=2)>]## # Find the nearest node to the location (1, 2, 3)print(tree.search_nn((1, 2, 3)))
阅读全文
0 0
- kd tree python 搜索
- kd-tree in Python
- KD-Tree Python实现
- kd-tree搜索近邻点
- KD tree算法(2)-最近邻搜索KD tree
- kd-tree
- KD Tree
- KD Tree
- kd-tree
- kd-tree
- kd-tree
- kd tree
- KD-Tree
- Kd-tree
- kd-tree
- kd-tree
- kd-tree
- kd-tree
- vue项目的搭建
- 超时代码 01 matrix
- 一起来学SQL(二)
- 第四周项目 ONE---建立单链表
- HBuilder快捷键
- kd tree python 搜索
- js动画旋转与缩放
- 点击listview条目跳转
- css3属性选择器
- Eclipse jee 创建Servlet模板
- sqoop安装
- vim的3种基本模式
- Go小tips
- c语言操作符