Indian Prime Minister Mr.Narendra Modi is the 12th most followed person on Twiiter. This repo is entirely apart from politics. It's just for educational purpose. This project involves the following :
- ETL
- Visualize
- Classification
- Sentiment Analysis
Libraries used :
- Tweepy
- wordcloud
- numpy
- pandas
- seaborn
To extract data from the we should have a twitter developer account. After having an developer account generate the credentials and insert in the notebook as in the repo. Once the credentials and connections are triggered we are good to go. With this we can extract any twiiter handle. Here we focus on Indian PM. Every tweet has around 30 features such as tweet content , date , number of likes , retweets , device etc.,
After extracting the tweets it's completely looks like messed up. Next step we have to transform the data so that it could be analysable. After transformation we do some statistical analysis of the tweets.
- Mean of the tweet length
- Most liked tweet
- Most Retweeted tweet
- Plotting dates with likes
- plotting dates with retweets
After doing some statisitical analysis let's do some correlation. The result medium length tweets gets more likes as well as retweets.
There are three types of sentiment
- Positive
- Neutral
- Negative
With this knowledge we loop over the tweets and using the TextBlob library we find the polarity of the tweet and classify accordingly. As a result
- Positive Tweets - 43.7%
- Negative tweets - 6.5%
- Neutral tweets - 49.8%
Let's find how many times he tweeted about ELECTIONS. He tweeted 20 times about the elections.
Correlations between the tweet's features:
Sentiment analysis result :
Word cloud:
Boxes are because of the Language mismatch. PM used Hindi and other languages also so wordcloud can't plot the other languages in the cloud.
Hope you enjoyed and learnt a lot. Things which can be added in the project:
- Classify tweets by devices.
- Word count by separate years.
- Deep analysis of Negative tweets.
- Extract State name mentioned frequently
- Finally your golden idea...
Inspired by the article Rodolfo Ferro
Thank You! Have a great day 😄