如何计算两列之间的余弦相似度? - Python

时间:2016-02-28 09:59:17

标签: python cosine-similarity

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'])

我想获得st和pt的每一行之间的余弦相似性,并将其存储在df_all ['相似性']中。

1 个答案:

答案 0 :(得分:0)