Welcome!

Sentiment Analysis in Python

Violeta Misheva

Data Scientist

What is sentiment analysis?

 

Sentiment analysis is the process of understanding the opinion of an author about a subject.

Sentiment Analysis in Python

What goes into a sentiment analysis system?

First element: Opinion/emotion

  • Opinion (polarity): pos, neutral, neg

positive, neutral and negative polarity

 

  • Emotion

an example of different emotions

Sentiment Analysis in Python

What goes into a sentiment analysis system?

Second element: subject

  • Subject of discussion: What is being talked about ?

_The camera on this phone is great but its battery life is rather disappointing. _

Third element: opinion holder

  • Opinion holder (entity): By whom?
Sentiment Analysis in Python

Why sentiment analysis?

  • Social media monitoring
    • Not only what people are talking about but HOW they are talking about it
    • Sentiment can be found also in forums, blogs, news
  • Brand monitoring
  • Customer service
  • Product analytics
  • Market research and analysis
Sentiment Analysis in Python

Let's look at movie reviews!

data.head()

top 5 rows of the IMDB movie reviews dataset

Sentiment Analysis in Python

How many positive and negative reviews?

data.label.value_counts()
0    3782
1    3719
Name: label, dtype: int64
Sentiment Analysis in Python

Percentage of positive and negative reviews

data.label.value_counts() / len(data)
0    0.504199
1    0.495801
Name: label, dtype: float64
Sentiment Analysis in Python

How long is the longest review?

length_reviews = data.review.str.len()
type(length_reviews)
pandas.core.series.Series
# Finding the review with max length
max(length_reviews)
0    667
1    2982
2    669
3    1087
....
Sentiment Analysis in Python

How long is the shortest review?

length_reviews = data.review.str.len()
# Finding the review with min length
min(length_reviews)
0    667
1    2982
2    669
3    1087
4    724
....
Sentiment Analysis in Python

Let's practice!

Sentiment Analysis in Python

Preparing Video For Download...