kNN algorithm implemented