Difference between scipy.spatial.KDTree and scipy.spatial.cKDTree

前端 未结 3 1413
春和景丽
春和景丽 2021-02-02 07:22

What is the difference between these two algorithms?

相关标签:
3条回答
  • 2021-02-02 07:47

    In a use case (5D nearest neighbor look ups in a KDTree with approximately 100K points) cKDTree is around 12x faster than KDTree.

    0 讨论(0)
  • 2021-02-02 07:54

    Currently, both have almost same APIs, and cKDTree is faster than KDTree. So, In the near future, SciPy developers are planning to remove KDTree, and cKDTree will be renamed to KDTree in a backwards-compatible way.

    Ref: Detailed SciPy Roadmap — SciPy v1.6.0.dev Reference Guide http://scipy.github.io/devdocs/roadmap-detailed.html#spatial

    0 讨论(0)
  • 2021-02-02 08:01

    cKDTree is a subset of KDTree, implemented in C++ wrapped in Cython, so therefore faster.

    Each of them is

    a binary trie, each of whose nodes represents an axis-aligned hyperrectangle. Each node specifies an axis and splits the set of points based on whether their coordinate along that axis is greater than or less than a particular value.

    but KDTree

    also supports all-neighbors queries, both with arrays of points and with other kd-trees. These do use a reasonably efficient algorithm, but the kd-tree is not necessarily the best data structure for this sort of calculation.

    0 讨论(0)
提交回复
热议问题