spamosaic.MNN.nn_annoy

spamosaic.MNN.nn_annoy(ds1, ds2, names1, names2, norm=True, knn=20, metric='euclidean', n_trees=10, save_on_disk=False)[source]

Approximate nearest neighbor search using Annoy index.

Parameters:
  • ds1 (np.ndarray) – Query dataset.

  • ds2 (np.ndarray) – Reference dataset.

  • names1 (list of str) – Identifiers for ds1.

  • names2 (list of str) – Identifiers for ds2.

  • norm (bool, default=True) – Whether to L2 normalize datasets before indexing.

  • knn (int) – Number of nearest neighbors to retrieve.

  • metric (str, default='euclidean') – Distance metric (‘euclidean’, ‘manhattan’, etc.).

  • n_trees (int, default=10) – Number of trees to build in Annoy index.

  • save_on_disk (bool, default=False) – Whether to write index to disk.

Returns:

Set of nearest neighbor pairs.

Return type:

Set[Tuple[str, str]]