Metric Trees

Metric tree in an indexing structure that allows for efficient KNN search

Metric tree organizes a set of points hierarchically

  • It's a binary tree: nodes = sets of points, root = all points
  • sets across siblings (nodes on the same level) are all disjoint
  • at each internal node all points are partitioned into 2 disjoint sets

Notation:

  • let N(v) be all points at node v
  • left(v),right(v) - left and right children of v

Splitting a node:

  • choose two pivot points p_l and p_r from N(v)
  • ideally these points should be selected s.t. the distance between them is largest:
    • (p_l,p_r)=\arg \max _{p_l,p_r\in N(v)}\left \| p_1-p_2 \right \|
    • but it takes O(n^2)(where n=\left | N(v) \right |) to find optimal p_l, p_r
  • heuristic:
    • pick a random point p \in N(v)
    • then let p_l be point farthest from p
    • and then let p_r be point farthest from p_l
  • once we have (p_l, p_r) we can partition:
    • project all points onto a line u=p_r-p_l
    • find the median point A along the line u
    • all points on the left of A got to left(v), on the right of A - to right(v)
    • by using the median we ensure that the depth of the tree is O(\log N) where N is the total number of data points
    • however finding the median is expensive
  • heuristic:
    • can use the mean point as well, i.e. A=(p_l+p_r)/2
  • let L be a d-1 dimensional plane orthogonal to u that goes through A
    • this L is a decision boundary - we will use it for querying

After metric tree is constructed at each node we have:

  • the decision boundary L
  • a sphere \mathbb B s.t. all points in N(v) are in this sphere
    • let center(v) be the center of \mathbb B and r(v) be the radius
    • so N(v)\subseteqq \mathbb B(center(v), r(v))

MT-DFS(q) - the search algorithm

  • search in a Metric Tree is a guided Depth-First Search
  • the decision boundary L at each node n is used to decide whether to go left or right
    • if q is in the left , then go to left(v), otherwise - to right(v)
    • (or can project the query point to u, and then check if q< A or not)
  • all the time we maintain x: nearest neighbor found so far
  • let d=\left \| x-q \right \| - distance from best x so far to the query
  • we can use d to prune nodes: we can check if node is good or no point can better than x
    • no point is better than x if \left \| center(r)-q \right \|-r(v)\geqslant d. That means if the hyper-sphere intersects with current candidates sphere

This algorithm is very efficient when dimensionality is \leqslant 30

  • but slows down when it increases

Observation:

  • MT often finds the NN very quickly and then spends 95% of the time verifying that this is the true NN
  • can reduce this time with Spill-Tree
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,178评论 0 10
  • 随着年龄的增长,父母健康的下降,村里一个个老年人的离去,甚至现在还能想到小时候他们叫喊着:孩子,别调皮,小心过往的...
    揽叶阅读 1,423评论 0 0
  • 上小学的时候,学校离家远,父母不放心,让我每天和同村的同学小抲一起上学。 那时候跟现在上午和下午课不一样,而是早中...
    我在乎的仅此而已阅读 4,597评论 0 0
  • 5215-谢志刚 转变思维,提高游戏力 英国著名剧作家王尔德曾说:“人生太重要,不要沉重以待。”工作也是一样,不能...
    剽悍的jerry阅读 1,625评论 1 1
  • 对于都市崇尚单身的富家子弟,男人三十是如花的年纪,婚姻是阻挡自由的围墙,然而在农村,二十来岁没有结婚就会被家里催婚...
    文案大咖秀阅读 6,283评论 0 0

友情链接更多精彩内容