kNN algorithm with improved results