I am using TextBlob
i am training my classifier
on a training set after that i am successfully able to get the classified out put
Bit how can i get the score of a particular text in terms of positive or negativity should i put scores of sentiments in my training data
here is what i have tried
from textblob import TextBlob
from textblob.classifiers import NaiveBayesClassifier
train = [
('I love this sandwich.', 'pos'),
('This is an amazing place!', 'pos'),
('I feel very good about these beers.', 'pos'),
('I do not like this restaurant', 'neg'),
('I am tired of this stuff.', 'neg'),
("I can't deal with this", 'neg'),
("My boss is horrible.", "neg")
]
cl = NaiveBayesClassifier(train)
cl.classify("I feel amazing!")
Here is the output
'pos'
How can i get the score of this like pos .7 or in any other format
You can do something like the following: source here
>>> prob_dist = cl.prob_classify("I feel amazing!")
>>> prob_dist.max()
'pos'
>>> round(prob_dist.prob("pos"), 2)
0.63
>>> round(prob_dist.prob("neg"), 2)
0.37