2

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? – Golden Lion Feb 15 '21 at 22:35
  • naive bayes is a classifer combined in a pipeline with countvectorize in the preprocessing part of the pipeline. – Golden Lion Mar 08 '21 at 12:47

1 Answers1

-1

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
Golden Lion
  • 129
  • 6
  • 1
    Downvoted. This doesn't seem to answer the question. From my perspective the asker is asking a mathematical formula. –  Mar 08 '21 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 – Golden Lion Mar 08 '21 at 13:09
  • 1
    That is not the point. Answers should be based on the question asked, not what is practical or easy. –  Mar 08 '21 at 13:10
  • The question is out of context then and should be removed. – Golden Lion Mar 08 '21 at 13:12
  • How can I apply naive Bayes classifier for three classes (Positive, Negative and Neutral) in text data? The Sentence implies a working solution which I provided using the TextBlog api . naive Bayes classifier is a classifier in the pipeline. You must use textblob to get the sentiment and polarity of the sentence then countvectorize the text into tokens for vectorization to be used by the classifier. – Golden Lion Mar 08 '21 at 13:13
  • 1
    Doesn't seem like it. –  Mar 08 '21 at 13:14
  • 1
    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. –  Mar 08 '21 at 13:15
  • the question about log-likelihood implies an misunderstanding of where sentiment is determined. Sentiment is not part of the bayes classifer. I clarified the content. – Golden Lion Mar 08 '21 at 13:17