On Thursday, December 6, 2012 2:15:53 PM UTC-8, [email protected] wrote: > I am looking for some example of implementing Cosine similarity in python. I > searched for hours but could not help much. NLTK seems to have a module but > did not find examples. Should be easy with numpy: import numpy as np
def cos(v1, v2):
return np.dot(v1, v2) / (np.sqrt(np.dot(v1, v1)) * np.sqrt(np.dot(v2,
v2)))
HTH,
--
Miki
--
http://mail.python.org/mailman/listinfo/python-list
