Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

Humans are emotional beings — we express joy, anger, sadness, and excitement through words, tone, and even silence. But can machines pick up on these emotional signals?
The answer is: not exactly like humans, but thanks to Sentiment Analysis, AI can analyze, interpret, and even respond to human emotions expressed in text, speech, or visuals. This blog explores how sentiment analysis works, its real-world uses, limitations, and how you can try it with code!
Sentiment Analysis, also known as opinion mining, is a Natural Language Processing (NLP) technique used to determine the emotional tone behind a piece of text.
It tries to classify a statement as:
Some advanced models also detect:
Text Preprocessing
Tokenization
Feature Extraction
Sentiment Classification
from textblob import TextBlob
text = "I absolutely love this movie. It's brilliant!"
blob = TextBlob(text)
print("Text:", text)
print("Sentiment Polarity:", blob.sentiment.polarity) # Range -1 to +1
print("Sentiment Subjectivity:", blob.sentiment.subjectivity) # 0 to 1
Output:
Text: I absolutely love this movie. It's brilliant!
Sentiment Polarity: 0.85
Sentiment Subjectivity: 0.75
🔹
Polarity > 0→ Positive
🔹Polarity < 0→ Negative
🔹 Subjectivity tells how opinion-based the text is
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
text = "I'm so mad this app keeps crashing every time 😡"
scores = analyzer.polarity_scores(text)
print("Text:", text)
print("Scores:", scores)
Output:
Text: I'm so mad this app keeps crashing every time 😡
Scores: {'neg': 0.593, 'neu': 0.407, 'pos': 0.0, 'compound': -0.6597}
🔸
compound < -0.05→ Negative
🔸compound > 0.05→ Positive
🔸 Otherwise → Neutral
| Domain | Application |
|---|---|
| E-commerce | Analyze customer reviews to improve products |
| Social Media | Track brand reputation on Twitter/X, Instagram |
| Customer Support | Prioritize angry/sad customers for quick replies |
| Finance | Gauge public opinion before investing |
| Politics | Monitor voter sentiment in elections |
AI doesn’t feel, but it can learn patterns of how emotions are typically expressed in data. Through supervised training on massive datasets, it picks up cues from:
AI mirrors our emotions, but with limitations.
Using HuggingFace Transformers and a pre-trained model like bhadresh-savani/distilbert-base-uncased-emotion:
from transformers import pipeline
emotion = pipeline("text-classification", model="bhadresh-savani/distilbert-base-uncased-emotion")
text = "I'm feeling really low today. Nothing seems to help."
result = emotion(text)
print(result)
Output:
[{'label': 'sadness', 'score': 0.991}]
You can use ChatGPT or any LLM for sentiment detection without writing code.
Example prompt:
Prompt: Analyze the following review and tell me whether it is positive, negative, or neutral, and why:
“The delivery was delayed and the item arrived damaged.”
Output:
Negative – The review indicates dissatisfaction due to late delivery and product condition.
While AI may not feel your joy or heartbreak, it can recognize emotional patterns with surprising accuracy. With tools like TextBlob, VADER, and transformer-based models, even beginners can experiment with sentiment analysis.
As AI improves, we’ll move from just “reading” emotions to responding with empathy — making our digital interactions more human than ever before.
Informative and Insightful