KD-Tree Demo

This diagram visualizes a KD-tree for a \(1\)-NN classifier. On the left, we plot the dataset along with the boundary lines of the tree and the decision boundary of \(k\)-NN. On the right, we visualize the tree itself. You can also click-and-drag the points to change the dataset, and double-click to add/remove/change points. Mouse-over the figure to see how various test points would interact with the KD-tree. The differently shaded regions in the figure indicate points that require different numbers of distance evaluations to classify in the tree. The grayed-out parts of the tree indicate computations that were saved by using the tree.