AI in Motion

Natural Language ProcessingBeginner1:16 video6 chapters

Sentiment Analysis and Text Classification — lecture notes

Is this review positive or negative? See how word evidence adds up, why negation is tricky, and how modern classifiers are built.

▶ Watch the animated lecture

0:001. Introduction

Introduction — Sentiment Analysis and Text Classification

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.

0:112. Adding up evidence

Adding up evidence — Sentiment Analysis and Text Classification

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.

0:343. The recipe

The recipe — Sentiment Analysis and Text Classification

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.

0:454. Classic vs modern

Classic vs modern — Sentiment Analysis and Text Classification

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.

0:575. Uses

Uses — Sentiment Analysis and Text Classification

Text classification powers review analysis, spam and toxicity filters, routing emails and support tickets, and tracking public opinion.

1:066. Recap

Recap — Sentiment Analysis and Text Classification

To recap. Sentiment analysis classifies feelings. Word evidence adds up into a probability, context handles negation, and fine-tuned Transformers are today’s standard.

Key takeaways

  • Sentiment analysis is text classification into positive/negative (or more classes).
  • Simple models add word weights and apply a sigmoid.
  • Negation (“not bad”) and sarcasm require context.
  • Fine-tuned Transformers handle context far better than bag-of-words models.

Check yourself

  1. Why is “Not bad at all” difficult for a word-weight model?
    Show answer

    Individual words look negative but the phrase is positive — Negation flips meaning; context is needed.

  2. What turns the summed word weights into a probability?
    Show answer

    A sigmoid — The sigmoid squashes the total into 0–1.

  3. Which approach best understands context?
    Show answer

    A fine-tuned Transformer model — Transformers represent words in context.

Go deeper

© 2026 Janin A Apurba, CSE, AUST · Advanced ICT Officer, CNRS-UNHCR. All rights reserved. Notes for the animated lecture at https://ai-in-motion.vercel.app/watch/sentiment-and-text-classification.html