Search code examples
pythongensimword2vecsimilaritycosine-similarity

Python3, word2vec, How can I get the list of similarity rank about "price" in my model


In gensim's word2vec python, I want to get the list of cosine similarity for "price".

I read the document of gensim word2vec, but document it describes most_similar and n_similarity function)()

I want the whole list of similarity between price and all others.


Solution

  • If you call wv.most_similar('price', topn=len(wv)), with a topn argument of the full vocabulary count of your model, you'll get back a ranked list of every word's similarity to 'price'.

    If you call with topn=0, you'll get the raw similarities with all model words, unsorted (in the order the words appear inside wv.index2entity).