【发布时间】:2017-05-08 23:03:00
【问题描述】:
您好,我有以下清单:
listComments = ["comment1","comment2","comment3",...,"commentN"]
我创建了一个 tfidf 矢量化器来从我的 cmets 获取模型,如下所示:
tfidf_vectorizer = TfidfVectorizer(min_df=10,ngram_range=(1,3),analyzer='word')
tfidf = tfidf_vectorizer.fit_transform(listComments)
现在为了进一步了解我的模型,我想获得最具代表性的特征,我尝试了:
print("these are the features :",tfidf_vectorizer.get_feature_names())
print("the vocabulary :",tfidf_vectorizer.vocabulary_)
这给了我一个我认为我的模型用于矢量化的单词列表:
these are the features : ['10', '10 days', 'red', 'car',...]
the vocabulary : {'edge': 86, 'local': 96, 'machine': 2,...}
但是我想找到一种方法来获得 30 个最具代表性的特征,我的意思是在我的 tfidf 模型中达到最高值的词,具有最高逆频率的词,我正在阅读文档但我不是能够找到这个方法我真的很感激这个问题的帮助,在此先感谢,
【问题讨论】:
标签: scikit-learn tf-idf