KNN classification with kd-tree