MCPcopy Create free account
hub / github.com/cosdata/cosdata / cosine_sim_matrix

Function cosine_sim_matrix

tests/test-dataset-streaming.py:330–336  ·  view source on GitHub ↗

Compute cosine similarity between each row in A and each row in B

(A, B)

Source from the content-addressed store, hash-verified

328 return False
329
330def cosine_sim_matrix(A, B):
331 """Compute cosine similarity between each row in A and each row in B"""
332 A = A / np.linalg.norm(A, axis=1, keepdims=True)
333 B = B / np.linalg.norm(B, axis=1, keepdims=True)
334 A[np.isnan(A)] = 0
335 B[np.isnan(B)] = 0
336 return np.dot(A, B.T)
337
338def generate_brute_force_results(dataset_name, quick_test=False):
339 """Generate brute force results by processing dataset in chunks"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected