maxfuse.spatial_utils.get_spatial_knn_indices

maxfuse.spatial_utils.get_spatial_knn_indices(locations, n_neighbors=15, method='kd_tree')[source]

Compute k-nearest neighbors of locations.

Parameters:
  • locations (np.ndarray of shape (n_samples, 2)) – Data matrix

  • n_neighbors (int) – Number of nearest neighbors

  • method (str, default='kd_tree') – Method to use when computing the nearest neighbors, one of [‘ball_tree’, ‘kd_tree’, ‘brute’]

Returns:

knn_indices (np.ndarray of shape (n_samples, n_neighbors)) – Each row represents the knn of that sample