2
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$ Commented Feb 15, 2021 at 22:35
  • $\begingroup$ naive bayes is a classifer combined in a pipeline with countvectorize in the preprocessing part of the pipeline. $\endgroup$ Commented Mar 8, 2021 at 12:47

1 Answer 1

-1
$\begingroup$

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
$\endgroup$
8
  • 1
    $\begingroup$ Downvoted. This doesn't seem to answer the question. From my perspective the asker is asking a mathematical formula. $\endgroup$
    – user9947
    Commented Mar 8, 2021 at 13:07
  • $\begingroup$ 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 $\endgroup$ Commented Mar 8, 2021 at 13:09
  • 1
    $\begingroup$ That is not the point. Answers should be based on the question asked, not what is practical or easy. $\endgroup$
    – user9947
    Commented Mar 8, 2021 at 13:10
  • 1
    $\begingroup$ Doesn't seem like it. $\endgroup$
    – user9947
    Commented Mar 8, 2021 at 13:14
  • 1
    $\begingroup$ 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. $\endgroup$
    – user9947
    Commented Mar 8, 2021 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .