Skip to content

Commit

Permalink
fix: conversion of cosine distance to cosine similarity is incorrect (#…
Browse files Browse the repository at this point in the history
…3441)

Co-authored-by: Mona Shaheen <mona.shaheen@dynamicyield.com>
  • Loading branch information
monash849 and monash8 authored Mar 3, 2023
1 parent f260d1e commit 63fce18
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gensim/similarities/annoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ def most_similar(self, vector, num_neighbors):
ids, distances = self.index.get_nns_by_vector(
vector, num_neighbors, include_distances=True)

return [(self.labels[ids[i]], 1 - distances[i] / 2) for i in range(len(ids))]
return [(self.labels[ids[i]], 1 - distances[i] ** 2 / 2) for i in range(len(ids))]

0 comments on commit 63fce18

Please sign in to comment.