MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / compute_recall

Function compute_recall

sample/python/utils.py:25–34  ·  view source on GitHub ↗

Compute recall@topk: fraction of gt top-k found in returned top-k.

(ids: np.ndarray, gt: np.ndarray, topk: int)

Source from the content-addressed store, hash-verified

23# ──────────────────────────────────────────────
24
25def compute_recall(ids: np.ndarray, gt: np.ndarray, topk: int) -> float:
26 """Compute recall@topk: fraction of gt top-k found in returned top-k."""
27 nq = ids.shape[0]
28 total_correct = 0
29 for i in range(nq):
30 gt_set = set(gt[i, :topk].tolist())
31 for j in range(topk):
32 if ids[i, j] in gt_set:
33 total_correct += 1
34 return total_correct / (nq * topk)
35
36# ──────────────────────────────────────────────
37# Clustering

Callers 3

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 1

setClass · 0.85

Tested by

no test coverage detected