Redid kNN implementation to make more use of matrix manipulation and less looping