โ† Back to Portfolio

Public Sentiment on Agnipath

An NLP-driven case study analyzing Twitter reactions to the Agnipath government scheme.

Python Tweepy API VADER Sentiment TextBlob Pandas

Analysis Pipeline

๐Ÿ“ก

Data Extraction

Fetched 50+ real-time tweets using Tweepy API based on hashtags like #AgnipathScheme.

๐Ÿงน

Preprocessing

Cleaned text using Regex & NLTK to remove noise, links, mentions, and stopwords.

๐Ÿง 

Modeling

Applied VADER (Rule-based) and TextBlob (Lexicon-based) models to classify sentiment.

Key Insights & Visualization

VADER Sentiment Distribution

VADER identified a higher percentage of negative sentiment compared to TextBlob.

Topic Word Cloud

Most frequent terms appearing in the analyzed tweets.

Word Cloud

Sample Classification

Positive (VADER)

"smart city surat engine bjp government in surat..."

Positive (VADER)

"plz major sahab dont have any idea after agnipa..."

Negative (VADER)

"nepal stopped recruitment since india announced..."

Negative (VADER)

"congressinsults patriotsshivajisavarkararmedfor..."

Neutral (VADER)

"Detailed breakdown of the new recruitment policy criteria..."

Conflict Analysis

Different models perceive sentiment differently. We compared TextBlob and VADER on the same dataset.

56%

Match Rate between TextBlob and VADER

22 tweets had conflicting labels out of 50.

Live Code Snippet

# fetching tweets q = '#AgnipathScheme -filter:retweets' tweets = client.search_recent_tweets(query=q, tweet_fields=['created_at', 'author_id'], max_results=50) # cleaning function def clean_tweet(text): text = re.sub(r'@[A-Za-z0-9]+', '', text) # remove mentions text = re.sub(r'#', '', text) # remove hashtags text = re.sub(r'RT[\s]+', '', text) # remove RT return text # applying vader analyzer = SentimentIntensityAnalyzer() df['vader_score'] = df['text'].apply(lambda x: analyzer.polarity_scores(x)['compound'])
View Full Repository on GitHub โ†’