3.1. Exercises
Finding Neighbours Questions
Nearest Neighbours True or False
Calculating the Distance to a Query Point
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line won’t execute and you can test your code after each step.
Let’s calculate the closet Pokémon in the training set to a Snoodle (our made-up Pokémon)!
Snoodle has the following feature vector.
[[53, 77, 43, 69, 80, 57, 5]]
Which Pokémon in the training set, most resembles a Snoodle?
Tasks:
- Create a model and name it
nn(make sure you are finding the single closest Pokémon). - Train your model on
X_train. - Predict your Pokémon using
kneighborsand save it in an object namedsnoodles_neighbour. - Which Pokémon (the name) is Snoodle most similar to? Save it in an object named
snoodle_name.