我正在努力改进我的文本分类模型。
text = df['text']
count_vect = CountVectorizer(min_df=1,ngram_range=(1, 2),
stop_words="english", max_features=200)
count_vect.fit(text)
counts = count_vect.transform(text)
以下是示例输出:
[(u'spring', 386), (u'https', 341), (u'com', 317), (u'pr', 313), (u'for
the', 285), (u'the pr', 208), (u'need', 196), (u'session', 164),
(u'jp', 158), (u'png', 156), (u'updated', 154), (u'please', 152),
(u'see', 145)]
我想手动添加单词/频率,我认为这可能是一个很好的指标。 对此有何帮助?
答案 0 :(得分:0)
这样的东西?
total = sum([x[1] for x in counts])
frequencies = [(x[0], x[1]/total) for x in counts]