Questions tagged «tf-idf»

6
Python:tf-idf-cosine:查找文档相似性
我正在关注第1 部分和第2 部分中可用的教程。不幸的是,作者没有时间进行最后一节,涉及使用余弦相似度实际找到两个文档之间的距离。我在stackoverflow的以下链接的帮助下关注了本文中的示例,其中包括上述链接中提到的代码(只是为了使生活更轻松) from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text import TfidfTransformer from nltk.corpus import stopwords import numpy as np import numpy.linalg as LA train_set = ["The sky is blue.", "The sun is bright."] # Documents test_set = ["The sun in the sky is bright."] # Query stopWords = stopwords.words('english') vectorizer …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.