Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 26

Government Polytechnic, Aurangabad

(An Autonomous Institute of Government of Maharashtra)

SENTIMENT
ANALYSIS FOR
TWITTER
Guided By: Presented By:
Prof. S.M.Bankar Nirmiti S. Pardhe
AGENDA
Introduction
Sentiment Analysis
Sentiment Analysis for Twitter
Approaches for Sentiment Analysis
Lexicon Based Approach
Machine learning Based Approach
Naive Bayes Classifier
Sentiment Analysis For Covid-19
Challenges
Benefits
Conclusion
INTRODUCTION

 It’s
estimated that 90% of the world’s data is
unstructured, in other words it’s unorganized.

 Sentiment analysis helps businesses quickly make


sense of all their unstructured text by automatically
understanding, processing, and tagging it, in a matter
of minutes and with minimal human input.
SENTIMENT ANALYSIS
Sentiment analysis is the process of mining the sentiments from the
data that is available in online platforms and categorizing the opinion
towards a particular entity that falls on three different categories which
are positive, neutral and negative.
For example:-
“I am so happy today ,good morning to everyone”, is positive text.
“The movie was bad , That was unfortunate ’’, is a negative text.
“The product was ok’’, is a neutral text.
SENTIMENT ANALYSIS FOR
TWITTER
Social networks are the main resources to gather
information about people’s opinion and sentiments towards
different topics.
Twitter nowadays is one of the popular social
media which currently has over 300 millions accounts.
Eventually 6,000 tweets are done on the Twitter on a
second basis.
 It resembles to 3,50,000 tweets sent per
minute and 500 million tweets per day.
That makes it around 200 billion tweets per year!
STEPS FOR SA OF TWITTER DATA
Raw Twitter
Data

Extract and Store Tweets

Pre-processing Tweets

Feature Extraction

Sentiment Classification

Experimental result
DATA COLLECTION
For performing SA we need Twitter Data consisting of tweets. For collecting
the data and tweets , Twitter public API is available for General public for free
time . It is a part of data collection.

The collected data is a raw data. So, in order to apply the classifiers, it’s really
essential to pre-process the raw data that are collected
PRE-PROCESSING

A, am, the, • Hello Click here!


• ;) , :( , ^-^….
etc. • www.myhome.com

Tokenization Removing Stopwords Removing URLs , etc.

Like –  Yoouuuuu – you


Account id(@),
Ni8 – night
 Hungggrry - hungry
Retweet(RT), Fi8 - Fight
Hashtag(#)

Removing notations Compressing Words Decompressing Words


FEATURE EXTRACTION
Feature extraction is the process that identifies important features or
attributes of the data . Followings are the widely used Feature Extraction
methods:-
TF-IDF(Term Frequency and Inverse Document Frequency): These
features denote individual and distinct words and their occurrence
count.
Bag-of-words: Is a representation of words in the text that describes
the occurrence of words within a document.
BAG OF WORDS
For each token we have a feature column, this is called as text vectorization.
good movie not a did like
Good movie
1 1 0 0 0 0
Not a good movie
1 1 1 1 0 0
Did not like
1 0 1 0 1 1

To perceive some ordering:-


We can count token pairs , triplets also called as n-grams
1-grams for token
Good Movie Did not a …
2-grams for pairs movie

Good movie 1 1 0 0 …
Not a good movie 1 1 0 1 …
Did not like 0 0 1 0 …
Sentiment
SENTIMENT classification
CLASSIFICATION
TECHNIQUE
Machine
Lexicon Based
learning based
Approach
approach
LEXICON BASED Opinion or review
text
APPROACH Split into

Lexicon-Based Approach uses sentiment lexicon with


Sentences
information about which words and phrases are positive and
Stemming and
which are negative. cleaning

 A sentiment lexicon is a list of lexical features which are Bag of Words

generally labelled according to their semantic orientation as Compare with

either positive or negative.


Opinion Lexicon
Scoring
function

Sentiment score
MACHINE LEARNING APPROACH
The main objective of the machine learning techniques is in developing the
Algorithm which optimizes the performance of a system using the training data.
This provides a solution of the sentiment classification in two Sequential steps:

A)Training

1 ML Model
Training Data Algorithm

B)Prediction

Trained
2 New Data Predictions
Model

Naïve Bayes Classifier, Support Vector Machine (SVM), and Random Forest are the
well-known methods for sentiment classification through Machine Learning.
NAIVE BAYES ALGORITHM
An algorithm that implements classification is known as classifier.

Naïve Bayes classifier uses the concept of Bayes Theorem in which it finds
the maximum aspect of the probability of any word matching to a particular or
predefined class.
Given a Hypothesis A and evidence B, Bayes’ Theorem states that the
relationship between the probability of Hypothesis before getting the evidence
P(A) and the probability of the hypothesis after getting the evidence P (A | B)
is :
NAIVE BAYES CLASSIFIER
 So let us try to understand how Naïve Bayes classifier works with an
example:-
Positive Negative

Sr. no. Good Bad movie Sr.no. Good Bad movie


1 Yes - - 7 - Yes -
2 Yes - - 8 - Yes Yes
3 - - - 9 - - -
4 Yes - Yes 10 - Yes -
5 Yes Yes - 11 Yes - -
6 - - - 12 - - -

Probability:- 4/6 1/6 1/6 Probability:- 1/6 3/6 1/6


NAIVE BAYES CLASSIFIER
Positive Negative
Probability:- 4/6 1/6 1/6 Probability:- 1/6 3/6 1/6

Example, The movie was bad.

The movie was bad.

Probability that the sentence is Positive:-( (1-4/6)*1/6*1/6) = 0.02083


Probability that the sentence is Negative:-( (1-1/6)*3/6*1/6) = 0.07000

Since, P(Negative)>P(Positive),
the above mentioned sentence is Negative.
IMPLEMENTATION
Source code for Twitter sentiment analysis on Covid-19:-
IMPLEMENTATION
Source code for Twitter sentiment analysis on Covid-19:-
IMPLEMENTATION
Result for Twitter Sentiment analysis on Covid-19 :-
CHALLEN
GES

Irony and Defining


Comparison
Sarcasm neutral
BENEFITS

Consistent Real-Time Scalability


Criteria Analysis
TWITTER
SENTIMENT
ANALYSIS USE
CASE:-

Social Customer Market Brand Political


media service research monitoring campaigns
monitoring
FUTURE SCOPE
Sentiment analysis is a uniquely powerful tool for businesses that are
looking to measure attitudes, feelings and emotions regarding their brand. 

The future of sentiment analysis is going to continue to dig deeper, far


past the surface of the number of likes, comments and shares, and aim to
reach, and truly understand, the significance of social media interactions.

This forecast also predicts broader applications for sentiment analysis –


brands will continue to leverage this tool, but so will individuals in the
public eye, governments, nonprofits, education centers and many other
organizations.
CONCLUSION
Thus , sentiment analyse helps in determining people’s opinion .
Therefore Twitter sentiment analysis uses advance techniques to
analyse the sentiments of the text in the form of positive , negative
and neutral.

This can help to know of what’s being said about your product or
service on social media and can help you detect the overall product
review.
REFERENCES
1. https://www.analyticsvidhya.com/blog/2020/02/quick-introduction-bag-of-words-
bow-tf-idf/
2. https://www.researchgate.net/publication/283201292_Approaches_Tools_and_Appli
cations_for_Sentiment_Analysis_Implementation
3. https://monkeylearn.com/blog/sentiment-classification/
4. https://towardsdatascience.com/twitter-sentiment-analysis-using-fasttext-
9ccd04465597
5. https://www.researchgate.net/publication/336225950_Comparison_of_Naive_Bayes
_Support_Vector_Machine_Decision_Trees_and_Random_Forest_on_Sentiment_A
nalysis
Thank You!,
Any
Questions…?

You might also like