本文介绍了python sklearn KDTree与haversine距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试创建一个 WGS84 坐标的 KD 树并找到一定半径内的邻居
I try to create a KD tree of WGS84 coordinates and find neighbors within a certain radius
from sklearn.neighbors.dist_metrics import DistanceMetric
from sklearn.neighbors.kd_tree import KDTree
T = KDTree([[47.8665, 8.90123]], metric=DistanceMetric.get_metric('haversine'))
但得到以下错误:
ValueError: metric HaversineDistance is not valid for KDTree
如何在 KD 树中使用半正弦距离?
How can I use haversine distance in a KD-Tree?
推荐答案
k-d-tree 可以(据我所知)只能与 Minkowski 范数一起使用.
The k-d-tree can (to the best of my knowledge) only be used with Minkowski norms.
还有其他树,例如 sklearn 中的球树,或 ELKI 中的覆盖树,它们与Haversine距离一起工作,因为它是一个度量.
There are other trees such as the ball tree in sklearn, or the covertree in ELKI that work with Haversine distance because it is a metric.
这篇关于python sklearn KDTree与haversine距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!