From 4a3364735e7d29db38d065d1b12d67e697b7af6e Mon Sep 17 00:00:00 2001 From: Mona Shaheen Date: Wed, 8 Feb 2023 14:45:23 +0200 Subject: [PATCH] fix: conversion of cosine distance to cosine similarity is incorrect --- gensim/similarities/annoy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gensim/similarities/annoy.py b/gensim/similarities/annoy.py index e586b2d2e3..688985ca51 100644 --- a/gensim/similarities/annoy.py +++ b/gensim/similarities/annoy.py @@ -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))]