0

I have various keywords and phrases. For ex : Keywords - happy, sad, angry and phrase- happy to read, angry on him etc

I have these keywords and phrases in the form of word2vec . I need to check the distance between these keyword and phrase in order to check which keyword matches to which phrase.

I am using function cosine_similarity(v1,v2) from sklearn.metrics.pairwise. This function is returning a vector. I want to have distance in a digit or number form. so that I can keep threshold to conclude that these 2 vectors are similar. How to do that? How to convert that result vector into digit value

iRunner
  • 1,472
  • 6
  • 25
  • 40
  • use [euclidean distance](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.euclidean_distances.html) to get the distance between 2 words – rock321987 Dec 02 '19 at 07:21
  • You can take median of the result vector for deriving a single digit value. – Samiie Dec 02 '19 at 08:52
  • @Samiie : median is giving very low value even if both are same – iRunner Dec 02 '19 at 14:10
  • This link solved this : https://stackoverflow.com/a/35092200/645825 and gives distance between two vectors – iRunner Dec 02 '19 at 14:58
  • Does this answer your question? [How to calculate the sentence similarity using word2vec model of gensim with python](https://stackoverflow.com/questions/22129943/how-to-calculate-the-sentence-similarity-using-word2vec-model-of-gensim-with-pyt) – William Baker Morrison Feb 17 '21 at 20:19

0 Answers0