Questions tagged «tfidf»

3
哈希向量化器和tfidf向量化器有什么区别
我正在将文本文档的语料库转换为每个文档的单词向量。我已经尝试过使用TfidfVectorizer和HashingVectorizer 我了解a 不像a 那样HashingVectorizer考虑IDF分数TfidfVectorizer。我仍然使用a的原因HashingVectorizer是它在处理庞大数据集时具有的灵活性,如此处和此处所述。(我的原始数据集有3000万个文档) 目前,我正在处理45339个文档的样本,因此,我TfidfVectorizer也可以使用。当我在相同的45339文档上使用这两个矢量化器时,得到的矩阵是不同的。 hashing = HashingVectorizer() with LSM('corpus.db')) as corpus: hashing_matrix = hashing.fit_transform(corpus) print(hashing_matrix.shape) 哈希矩阵形状(45339,1048576) tfidf = TfidfVectorizer() with LSM('corpus.db')) as corpus: tfidf_matrix = tfidf.fit_transform(corpus) print(tfidf_matrix.shape) tfidf矩阵形状(45339,663307) 我想更好地理解a HashingVectorizer和a 之间的区别TfidfVectorizer,以及这些矩阵大小不同的原因-尤其是单词/术语的数量。
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.