Locally Adaptive Nearest Neighbor Algorithms