FAQ: K-Nearest Neighbors - Choosing K

This community-built FAQ covers the “Choosing K” exercise from the lesson “K-Nearest Neighbors”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Machine Learning

FAQs on the exercise Choosing K

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi there,

In step 2, the judgement on whether the code is correct has some problem: looping over a dictionary in python does not give a predictable order. A correct code may still be judged as wrong. The only solution I found is to run the same code multiple times until it pass… This is not very pleasant. Could you please change this part? Many thanks!

Hi! Can anyone explain to me how K-Nearest Neighbors is considered machine learning algorithm? It seems like we’re writing the entire algorithm ourselves with a given formula of distance formula. We’re not training the model by feeding it training sets and back propagating. It seems like a pretty standard algorithm for me. Can anyone help me understand? Thank you!

You have wrote and algorithm that uses movie data and the purpose of that algorithm is to predict the result of a movie that is not present in the dataset. I’m new to this too but I think that the goal of a machine learning software is to use previous data, study it and with that try to predict future data, and where is going to fall your future data.

In this case we are trying to predict if a movie will have a IMDB rating above 7.

1 Like