Sentiment analysis using Twitter
Sentiment analysis is a technique that involves extracting opinion from text
A sample use cause can be using tweets from Twitter to discover people feelings about a product or service
Helps find polarity (positive or negative)
Data sources: Review sites, blogs, forums, social media, etc.
Text data can either be facts (mostly neutral) or opinions (consists of polarity)
Sentiment Analysis method
Rule based
Matching words with sentiment scores from a lexicon (sample of words with associated polarity scores)
No training required
Not so accurate
Automatic
Trained pattern matching algorithm will predict a word's sentiment
Uses machine learning such as classification algorithm to find polarity
More accurate and scalable
Needs more training data
Sentiment analysis using Twitter API and Vader python framework
Step 1: Create a Twitter application to access twitter data
Step 2: Get keys and access tokens to access twitter API
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
Step 3: Install dependencies
Step 4: Import dependencies
Tweepy: Accessing data from Twitter
Vader: For sentiment analysis
Step 5: Search for tweets
Note: The response from tweepy search() contains metadata information of tweets.
Step 6: Perform sentiment analysis using Vader
Last updated
Was this helpful?