简体   繁体   中英

How to calculate cosine similarity between two columns? - Python

tfvect = TfidfVectorizer(use_idf=True, stop_words = 'english')
wholeword = df_all['search_term']+" "+df_all['product_title']
vocab = tfvect.fit_transform(wholeword)
st = tfvect.transform(df_all['search_term'])
pt = tfvect.transform(df_all['product_title'])

I want to get the cosine similarity between each row of st and pt and store it in df_all['similarity'].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM