Sentiment Analysis and Text Classification
Is this review positive or negative? See how word evidence adds up, why negation is tricky, and how modern classifiers are built.
📄 Illustrated notes · every chapter as a picture · printable
Quick quiz
3 questions to check your understanding.
Go deeper
University-level written lectures in The AI Lecture Hall:
Transcript
Introduction. Companies read thousands of reviews and comments every day. Sentiment analysis, a kind of text classification, tells them automatically whether people are happy or not.
Adding up evidence. A simple classifier gives each word a weight. Delicious pushes strongly towards positive. Slow and rude push towards negative. The weights add up, and a sigmoid turns the total into a probability. But look at the last sentence. Not bad at all is actually positive, yet word by word it looks negative. Negation is hard.
The recipe. The recipe: collect labelled texts, turn them into features, TF-IDF or embeddings from a pre-trained model, train a classifier, and evaluate it on held-out data.
Classic vs modern. Classic models are fast and explainable, but miss negation and sarcasm. Fine-tuned Transformer models read words in context, so they understand that not bad means good.
Uses. Text classification powers review analysis, spam and toxicity filters, routing emails and support tickets, and tracking public opinion.
Recap. To recap. Sentiment analysis classifies feelings. Word evidence adds up into a probability, context handles negation, and fine-tuned Transformers are today’s standard.