Created
February 2, 2019 12:30
-
-
Save davideanastasia/e9dffe78348284132115a026dd3d4ee2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_index = np.random.choice(taxi_data_pivot.shape[0]) | |
distances, indexes = model_knn.kneighbors( | |
taxi_data_pivot.iloc[query_index, :].values.reshape(1, -1), | |
n_neighbors = 3) | |
taxis = [taxi_data_pivot.index[idx] for idx in indexes.flatten()] | |
for i in range(0, len(distances.flatten())): | |
print('{0}: {1}, with distance of {2}'.format( | |
i, taxi_data_pivot.index[indexes.flatten()[i]], distances.flatten()[i])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment