Cosine Similarity

Miki Tebeka miki.tebeka at
Fri Dec 7 05:17:46 CET 2012

On Thursday, December 6, 2012 2:15:53 PM UTC-8, subhaba... at 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, v2) / (np.sqrt(, v1)) * np.sqrt(, v2)))


More information about the Python-list mailing list