for this examplewhere we're trying to compute the distance using our distance metric between movies and we end up with score of remembera far distance means it' not similarrightwe want the nearest neighborswith the smallest distance soa score of is pretty high number on scale of to so that' telling me that these movies really aren' similar let' do quick sanity check and see what these movies really areqsjounpwjf%jdu qsjounpwjf%jdu it turns out it' the movies goldeneye and get shortywhich are pretty darn different moviesyou knowyou have james bond action-adventureand comedy movie not very similar at allthey're actually comparable in terms of popularitybut the genre difference did it in okaysolet' put it all togethernextwe're going to write little bit of code to actually take some given movieid and find the knn soall we have to do is compute the distance between toy story and all the other movies in our movie dictionaryand sort the results based on their distance score that' what the following little snippet of code does if you want to take moment to wrap your head around itit' fairly straightforward we have little hfu/fjhicpst function that will take the movie that we're interested inand the neighbors that we want to find it'll iterate through every movie that we haveif it' actually different movie than we're looking atit will compute that distance score from beforeappend that to the list of results that we haveand sort that result then we will pluck off the top results