Skip to content Skip to sidebar Skip to footer

Nltk Sentiment Analysis Is Only Returning One Value

I seriously hate to post a question about an entire chunk of code, but I've been working on this for the past 3 hours and I can't wrap my head around what is happening. I have appr

Solution 1:

Naive Bayes Classifier usually works best when evaluating words that appear in the document, ignoring absence of words. Since you use

features['contains(%s)' % word] = (word in document_words)

each document is mostly represented by features with a value = False.

Try instead something like:

if word in document_words:
   features['contains(%s)' % word] = True

(you should probably also change the for loop for something more efficient than looping over all words in the lexicon, looping instead on words occurring in the document).

Post a Comment for "Nltk Sentiment Analysis Is Only Returning One Value"