Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

doc2vec similarity

from gensim.models import doc2vec
from scipy import spatial

d2v_model = doc2vec.Doc2Vec.load(model_file)

fisrt_text = '..'
second_text = '..'

vec1 = d2v_model.infer_vector(fisrt_text.split())
vec2 = d2v_model.infer_vector(second_text.split())

similairty = spatial.distance.cosine(vec1, vec2)
# similarity is how much two text differ from each other, higher values mean more distinct texts
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #similarity
ADD COMMENT
Topic
Name
8+7 =