KNN - diabetes accuracy

code : https://ide.codingblocks.com/s/291912

I have tried for a all odd values of k between 5-25
the max accuracy I am getting is 68%
please help with the code and approach

Hey @pgarg,
Your code is great and don’t worry about the accuracy. With KNN , you can achieve a maximum accuracy of around 70-73% with KNN.
For that you can try the following :

  1. Find the best value of K for which the model performs best . (try to take K as 17)
  2. Standardizing or normalizing your dataset.
  3. Averaging 2 or 3 different models predictions to get the final prediction.
  4. Currently you are calculating Euclidean Distance or l2_norm , you can also try different methods like manhattan distance , minkowski distance , hamming distance etc.

If you want to achieve accuracy around 85-90% then you need to switch to some other algorithms. They will really help you to work a lot on it.

I hope this helps you clear your doubt !
Happy Learning. :slight_smile:

With k=17 and minkowski distance I got accuracy of 78%
how can I normalize my data
and will the other alogorithims also be taught in this course

Yes great ! So 78% is the maximum accuracy you can achieve with KNN algorithm. Yes ofcourse other algorithms will be taught in the course ! I recommend you to continue with the further contents of the course…study different algorithms, and then try to use the same dataset to make predictions. You will realise that accuracy will rise eventually !

I hope this clears your doubt !
Please mark the doubt as resolved in your doubts section :slightly_smiling_face:
Happy Learning ! :slightly_smiling_face:

1 Like

Thanks a lot
Happy listening this

1 Like