Multivariate K-Nearest Neighbors | Dataquest
from scipy.spatial import distance normalized_listings = (dc_listings - dc_listings.mean())/(dc_listings.std()) normalized_listings['price'] = dc_listings['price'] first_listing = normalized_listings.iloc[['accommodates', 'bathrooms']] fifth_listing = normalized_listings.iloc[['accommodates', 'bathrooms']] first_fifth_distance = distance.euclidean(first_listing, fifth_listing) print(first_fifth_distance)
What I expected to happen:
The code was meant to output the Euclidean distance between the two attributes in the code above.
What actually happened:
But instead I have
NameError: name 'dc_listings' is not defined
I tried using the code in the answer section, it brought out the same thing.