Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Python :: pandas data profiling 
Python :: add x=y line to scatter plot python 
Python :: what if we multiply a string in python 
Python :: python hide input 
Python :: count number of each item in list python 
Python :: effektivwert python 
Python :: pandas select rows by multiple conditions 
Python :: import numpy financial python 
Python :: import get_object_or_404 
Python :: append dataframe pandas 
Python :: python flatten list 
Python :: print dictionary of list 
Python :: python rdp server 
Python :: pandas to dictionary 
Python :: how to check for missing values in pandas 
Python :: plot a circle in python using equation of a circle 
Python :: odd or even python 
Python :: pygame size of image 
Python :: how to use h5 file in python 
Python :: find factorial in python 
Python :: how to find an element in a list python 
Python :: pandas check if column is sorted 
Python :: django timezone settings 
Python :: give a function a name python 
Python :: how to make a multiple choice quiz in python with tkinter 
Python :: access row of dataframe 
Python :: how to give bar plot groupby python different colors 
Python :: slicing of tuple in python 
Python :: how to put a image in flask 
Python :: access django server from another machine 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =