Words Sentiment Score

We have explained how to get a sentiment score for words in Python. Instead of building our own lexicon, we can use a pre-trained one like the VADER which stands from _Valence Aware Dictionary and sEntiment Reasoner _and is specifically attuned to sentiments expressed in social media.

You can install the VADER library using pip like pip install vaderSentiment or you can get it directly from NTLK. You can have a look at VADER documentation.

Examples of Sentiment Scores

The VADER library returns 4 values such as:

  • pos: The probability of the sentiment to be positive
  • neu: The probability of the sentiment to be neutral
  • neg: The probability of the sentiment to be negative
  • compound: The normalized compound score which calculates the sum of all lexicon ratings and takes values from -1 to 1

Notice that the posneu and neg probabilities add up to 1. Also, the compound score is a very useful metric in case we want a single measure of sentiment. Typical threshold values are the following:

  • positive: compound score>=0.05
  • neutral: compound score between -0.05 and 0.05
  • negative: compound score<=-0.05

Let’s see these features in practice. We will work with a sample fo twitters obtained from NTLK.

#python #nltk #sentiment-analysis #sentiment #vader

How to Run Sentiment Analysis in Python using VADER
11.50 GEEK