vals.append (( d, Y[i] ))
here why are we taking Y[i] as a parameter??
K Nearest Neighbour's Algo
Hey @yash443388k, here we are using knn for classification problem, so basically for query point, we first find k nearest naeighbors to the query point, and than we need to do majority voting, so for getting classes of that k points, we need to do vals.append (( d, Y[i] )), so that we have distance and class label both for all the points.
Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. 
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.