Complete the code to import the KDTree class from scipy.spatial.
from scipy.spatial import [1] points = [[1, 2], [3, 4], [5, 6]] tree = KDTree(points)
The correct class name to import is KDTree with capital K, D, and T.
Complete the code to build a KDTree from a list of points.
points = [[2, 3], [5, 4], [9, 6], [4, 7], [8, 1], [7, 2]] tree = [1](points)
To build the tree, call KDTree(points).
Fix the error in the code to query the nearest neighbor of a point using the KDTree.
query_point = [3, 4] distance, index = tree.[1](query_point) print(f"Nearest point index: {index}, distance: {distance}")
The correct method to find nearest neighbors is query.
Fill both blanks to create a dictionary comprehension that maps each point to its distance from the query point using the KDTree.
distances = {tuple(point): tree.[1](point)[[2]] for point in points}Use query to get (distance, index), and index 0 gives the distance.
Fill all three blanks to create a dictionary comprehension that maps each point's index to the point itself if its distance from the query point is less than 5.
close_points = {i: points[i] for i in range(len(points)) if tree.query(points[i])[[1]] [2] [3]Use index 0 to get distance, then check if distance is less than 5.