<p>我想知道是否有人可以帮助我通过一个代码片段,演示如何训练朴素的贝叶斯分类器使用特征频率方法,而不是特征的存在。</p>
<p>我假设下面如第6章所示的<a href="http://nltk.googlecode.com/svn/trunk/doc/book/ch06.html#document-classify-all-words" rel="nofollow noreferrer">link text</a>是指使用Feature Presence(FP)创建一个featureset-</p>
<pre><code>def document_features(document):
document_words = set(document)
features = {}
for word in word_features:
features['contains(%s)' % word] = (word in document_words)
return features
</code></pre>
<p>请告知</p>