gensim.models.Word2Vec.similar_by_word¶
-
Word2Vec.
similar_by_word
(word, topn=10, restrict_vocab=None)[source]¶ Find the top-N most similar words.
If topn is False, similar_by_word returns the vector of similarity scores.
restrict_vocab is an optional integer which limits the range of vectors which are searched for most-similar values. For example, restrict_vocab=10000 would only check the first 10000 word vectors in the vocabulary order. (This may be meaningful if you’ve sorted the vocabulary by descending frequency.)
Example:
>>> trained_model.similar_by_word('graph') [('user', 0.9999163150787354), ...]