Sentiment Analysis

with sentimentR

Noah Christensen

The Problem

Suppose you are launching an exciting new meme…

meme ranked third best on Reddit

The Problem

  • Your only source of feedback is thousands of comments.

  • How do you turn this into workable data?

“This is hilarious!”
“Made me laugh out loud”
“Not bad”
“Meh”
“I don’t get it”
“Could be better”

The Solution

Sentiment Analysis

Natural language processing enables the vectorization of arbitrary text.

“This is hilarious!” Good
“Made me laugh out loud” Good
“Not bad” Neutral
“Meh” Bad
“I don’t get it” Bad
“Could be better” Neutral

The Solution

Outcome

  • Objective
  • Systemic
  • Automated

Now you do not need to read every comment to know how your meme is performing!

Sentiment Analysis

Vectorization

  • Computers do not process in good, neutral, and bad.
  • Sentiment Analysis assigns a decimal to each statement.
“This is hilarious!” Good 0.90
“Made me laugh out loud” Good 0.50
“Not bad” Neutral 0.21
“Meh” Bad -0.65
“I don’t get it” Bad -0.55
“Could be better” Neutral -0.17

Sentiment Analysis

Vectorization

What does this mean for me?

Now, you can convert qualitative data to quantitative data!

  • Objective data based on established standards
  • Consistency throughout implementation
  • Little room for researcher bias

Sentiment Analysis

Expanding beyond sentiment

At its core, sentiment analysis uses large dictionaries of words and their weights.

“excellent” 1.0
“awful” -1.0

\[ Sentiment(T) = \sum_{i=1}^{T_{length}}weight(T_i)\cdot valence(T_{i_{valence}}) \]

Sentiment Analysis ### Valencies

  • Some words indicate different connotations: Very, Slightly, Absolutely, Not, Never
  • SentimentR knows to process these words in a logical matter

Sentiment Analysis

Limitations

  • Words that are misspelled are dropped
  • Confusing syntax and double negatives cause confusion

It was not the case that I had an amazing time at the event bc it was teribl.

Sentiment: 0.1147079 (slightly positive)

Sentiment Analysis

Expanding beyond sentiment


Why is this useful?

You can use sentiment analysis to understand nearly any idea, not just positive or negative.

Applications

How is this useful?

  • Many companies use sentiment analysis to process customer feedback.
    • Customer surveys
    • Product reviews
    • Etc.
  • Political campaigns
  • Finance and Market

Applications

Getting started with code


sentimentr is very easy to use.


library(sentimentr)
texts <- c("I love this meme!", "This is okay.", "Not funny at all.")
sentiment(texts)


Don’t be fooled by simple implmentation – the algorithim behind this package is more sophisticated than several other packages.

Sentiment Analysis

Learn more about sentiment analysis at

https://cran.r-project.org/web/packages/sentimentr/sentimentr.pdf



Presenter

Noah Christensen

noah_christensen1@baylor.edu