KNN algorithm implemented by Java