Complete the code to import the function that computes distances between two sets of points.
from scipy.spatial.distance import [1] points1 = [[0, 0], [1, 1]] points2 = [[1, 0], [2, 2]] distances = [1](points1, points2) print(distances)
The cdist function computes distances between two collections of points.
Complete the code to compute Euclidean distances between two sets of points using cdist.
from scipy.spatial.distance import cdist points1 = [[0, 0], [1, 1]] points2 = [[1, 0], [2, 2]] distances = cdist(points1, points2, metric=[1]) print(distances)
The metric parameter set to 'euclidean' computes straight-line distances.
Fix the error in the code to correctly compute Manhattan distances between two sets of points.
from scipy.spatial.distance import cdist points1 = [[0, 0], [1, 1]] points2 = [[1, 0], [2, 2]] distances = cdist(points1, points2, metric=[1]) print(distances)
The metric parameter must be a string. For Manhattan distance, use 'cityblock' as a string.
Fill both blanks to create a dictionary of distances from points1 to points2 using cosine metric and convert the result to a list.
from scipy.spatial.distance import cdist points1 = [[1, 0], [0, 1]] points2 = [[1, 1], [0, 0]] dist_matrix = cdist(points1, points2, metric=[1]) dist_list = dist_matrix.[2]() print(dist_list)
Use 'cosine' as the metric string and tolist() to convert the numpy array to a Python list.
Fill all three blanks to compute Chebyshev distances between two sets of points and print the maximum distance value.
from scipy.spatial.distance import cdist points1 = [[1, 2], [3, 4]] points2 = [[5, 6], [7, 8]] dist_matrix = cdist(points1, points2, metric=[1]) max_dist = dist_matrix.[2]() print(max_dist[3])
Use 'chebyshev' as the metric string. To find the maximum value in the distance matrix, use dist_matrix.max(). Here, max is the attribute and () calls it as a method.