-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed incorrect doctags in most_similar #601 #994
Conversation
Thanks for the fix. |
@@ -460,7 +460,7 @@ def most_similar(self, positive=[], negative=[], topn=10, clip_start=0, clip_end | |||
return dists | |||
best = matutils.argsort(dists, topn=topn + len(all_docs), reverse=True) | |||
# ignore (don't return) docs from the input | |||
result = [(self.index_to_doctag(sim), float(dists[sim])) for sim in best if sim not in all_docs] | |||
result = [(self.index_to_doctag(sim + clip_start), float(dists[sim])) for sim in best if (sim+clip_start) not in all_docs] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8: space around binary operators.
Made the changes mentioned above. |
@@ -159,6 +160,12 @@ def model_sanity(self, model): | |||
self.assertEqual(list(zip(*sims))[0], list(zip(*sims2))[0]) # same doc ids | |||
self.assertTrue(np.allclose(list(zip(*sims))[1], list(zip(*sims2))[1])) # close-enough dists | |||
|
|||
# sim results should be in clip range if given | |||
clip_sims = model.docvecs.most_similar(fire1, clip_start=len(model.docvecs)//2, clip_end=len(model.docvecs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a clip_end as len(model.docvecs)*2//3
Thanks for the PR! |
most_similar() in doc2vec.py doesn't consider given clip range for tagID/indexes #601
fix: add clip_start to index_to_doctag's indexes.