Was not able to understand the code what you are trying to do exactly.
K-Nearest Neighbour
Hey @abhishekkundu86, it’s okay I understand it gets tough to understand in one go sometimes. I would suggest you to go through the following blog to understand the basic concepts of how KNN works… KNN implementation
If you feel there is anything u didn’t understand , do ask me again !
I hope this clears your doubt !
Happy Learning ! 
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.