I am trying to train a model for sentiment analysis and below is my trained Multinomial Naive Bayes Classifier returning an accuracy of 84%.
I have been unable to figure out how to use the trained model to predict the sentiment of a sentence. For example, I now want to use the trained model to predict the sentiment of the phrase "I hate you".
I am new to this area and any help is highly appreciated.
I don't know the dataset and what is semantic of individual dictionaries, but you are training your model on a dataset which has form as follows:
[[{"word":True, "word2": False}, 'neg'], [{"word":True, "word2": False}, 'pos']]
'neg'
label. If you want to predict you need to input a dictionary in a form: {"I": True, "Hate": False, "you": True}
.
MNB_classifier.classify({"love": True})
>> 'neg'
or MNB_classifier.classify_many([{"love": True}])
>> ['neg']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.