Skip to content

Commit

Permalink
Merge pull request #16 from IBM/fix-v.0.0.18
Browse files Browse the repository at this point in the history
🪲 Bug fix: Distance to similarity
  • Loading branch information
RaulFD-creator authored Aug 14, 2024
2 parents fbccfa3 + 3400976 commit 353c9cd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hestia/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def _embedding_distance(
target_embds: Optional[np.ndarray] = None,
distance: Union[str, Callable] = 'cosine',
threads: int = cpu_count(),
threshold: float = 0.0,
save_alignment: bool = False,
filename: str = None,
to_df: bool = True,
Expand All @@ -429,8 +430,11 @@ def _embedding_distance(
data = []
for idx in tqdm(range(mtx.shape[0])):
for idx2 in range(mtx.shape[1]):
value = mtx[idx, idx2]
if value < threshold:
continue
data.append({'query': idx, 'target': idx2,
'metric': mtx[idx, idx2]})
'metric': 1 - value})
df = pd.DataFrame(data)
if save_alignment:
if filename is None:
Expand Down

0 comments on commit 353c9cd

Please sign in to comment.