# How can I apply naive Bayes classifier for three classes (Positive, Negative and Neutral) in text data?

I found a naive Bayes classifier for positive sentiment or a negative sentiment Citius: A Naive-Bayes Strategy for Sentiment Analysis on English Tweets. But with most available datasets online, sentiments are classified into 3 types: positive, negative, and neutral.

How does the naive Bayes formula change for such cases? Or does it remain the same, and we only consider the positive and negative to calculate the log likelihoods-likelihoods?

• post a sample of the data your trying to classify. Will it have one output label or multiple? Are you using CountVectorizer or TfIDF to tokenize your words? Commented Feb 15, 2021 at 22:35
• naive bayes is a classifer combined in a pipeline with countvectorize in the preprocessing part of the pipeline. Commented Mar 8, 2021 at 12:47

Use TextBlob to get the text sentiment polarity and subjectivity. polarity is negative or positive sentiment and subjectivity is how factual the sentiment is.

my_valance=TextBlob(sentence)
df.loc[key,'sentiment_polarity']=my_valance.sentiment.polarity
df.loc[key,'sentiment_subjectivity']=my_valance.sentiment.subjectivity

• Downvoted. This doesn't seem to answer the question. From my perspective the asker is asking a mathematical formula.
– user9947
Commented Mar 8, 2021 at 13:07
• you want to reverse engineer the nlp equation for sentiment? why? just use the existing api TextBlog. you could get spacy nlp and then find the sentiment portion of the open source code and reverse engineer the calcualtions. certain words are weight negative and certain words are weighted positive and certain words are facts. Proximity to each other have a distance and a weight Commented Mar 8, 2021 at 13:09
• That is not the point. Answers should be based on the question asked, not what is practical or easy.
– user9947
Commented Mar 8, 2021 at 13:10
• Doesn't seem like it.
– user9947
Commented Mar 8, 2021 at 13:14
• The question asks about the formula used, not how would one classify although that is the end goal. In short the user wants to know how are things working under the hood.
– user9947
Commented Mar 8, 2021 at 13:15