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
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.