scSemiProfiler.utils.faiss_knn

scSemiProfiler.utils.faiss_knn(query, x, n_neighbors=1)[source]

Compute distances from a vector to its K-nearest neighbros in a matrix.

Parameters
  • query (numpy.array) – The query vector

  • X – The data matrix

  • n_neighbors (int) – How many neighbors to consider?

Return type

numpy.array

Returns

weights (distances)

Example

>>> faiss_knn(ma,mb,n_neighbors=1)