Sentiment analysis classifies the opinion or emotion expressed in text — product reviews, support tickets, survey comments, social media posts.
Levels of Detail
- Document-level: is this review positive or negative overall?
- Sentence-level: sentiment of each sentence.
- Aspect-based: sentiment towards specific aspects — "great battery, terrible screen".
Approaches
- Lexicons: count positive and negative words. Transparent but crude.
- Classic machine learning: bag-of-words features with logistic regression or Naive Bayes.
- Fine-tuned transformers: accurate on text similar to their training data.
- Large language models: can classify with instructions, handle nuance and explain their reasoning.
Common Pitfalls
- Sarcasm and irony: "Great, it broke again."
- Domain shift: a model trained on film reviews may misread medical feedback.
- Neutral and mixed text: many real comments aren't clearly positive or negative.
- Negation and comparisons: "not bad", "better than the last one".
- Language and dialect differences.
Evaluate on Your Data
Label a few hundred of your own texts and measure accuracy per class. Include mixed and neutral examples.
Using Results Responsibly
Aggregated sentiment trends are more reliable than individual scores. Pair scores with sample comments so people see what's driving them, and don't make consequential decisions about individuals from sentiment scores alone.