'KD tree' with custom distance metric

后端 未结 1 618
时光说笑
时光说笑 2021-01-15 15:06

I want to use \'KDtree\'(this is the best option. Other \'KNN\' algorithms aren\'t optimal for my project) with custom distance metric. I checked some answers here for simil

相关标签:
1条回答
  • 2021-01-15 15:24

    Scikit-learn's KDTree does not support custom distance metrics. The BallTree does support custom distance metrics, but be careful: it is up to the user to make certain the provided metric is actually a valid metric: if it is not, the algorithm will happily return results of a query, but the results will be incorrect.

    Also, you should be aware that using a custom Python function as a metric is generally too slow to be useful, because of the overhead of Python callbacks within the traversal of the tree.

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