ak_lpe#
- scio.scores.utils.ak_lpe(index, k, query, *, self_query=False)[source]#
Mean distance from \(\approx k\)-th nearest neighbors.
- Parameters:
index (
Index) – Search index.k (
int) – Number of neighbors to look up.query (
Tensor) – The query samples, not necessarily flattened. Shape(n_query, *sample_shape).self_query (
bool) – SeeIndex.search(). Requires one additional reference sample inindex. Defaults toFalse.
- Returns:
out (
Tensor) – Mean distance fromm-th nearest neighbors, withk / 2 < m <= 3 * k // 2. Shape(n_query,). Full ofnanifindex.ntotal < 3 * k // 2 + self_query.
Attention
If
indexuses the \(L^2\) metric, the “mean distance” actually ressembles a variance, sinceIndex.search()outputs the squared euclidian distance in that case.