Change k-NN implementation to use sparse matrix multiplication