statistical_learning
statistical_learning copied to clipboard
A little question
I found a small problem while running KD-tree.
If the target point has the same distance to more than one node, e.g., target = array([7.5, 3.5])
, it will throw the following error
TypeError: '<' not supported between instances of 'Node' and 'Node'
I think it's because heapq.nlargest()
need to compare items in heap. So it can't compare two items with the same distance, e.g., (1.5, Node1)
and (1.5, Node2)
. A quick solution is adding an index to each item, like (1.5, 1, Node1)
and (1.5, 2, Node2)
.