← Lessons

quiz vs the machine

Gold1330

Machine Learning

Sentiment Analysis

Deciding whether text is positive or negative.

4 min read · core · beat Gold to climb

Sentiment Analysis

Sentiment analysis classifies the emotional tone of text, most often as positive, negative, or neutral. Businesses use it to track reviews, social posts, and support tickets at scale.

The simplest approach is lexicon based. You keep a dictionary of words tagged with sentiment, then sum the scores in a document. This is transparent but brittle, because it reads words in isolation.

That brittleness shows up in three classic traps:

  • Negation, where not good flips the meaning of good
  • Sarcasm, where great, another delay means the opposite of praise
  • Context, where unpredictable is positive for a movie plot but negative for a car

Machine learning models handle these better by learning from labeled examples rather than fixed word scores. They pick up that the word not near a positive word should flip the prediction. Modern systems use embeddings and neural networks that read the whole sentence, capturing word order and interaction.

Sentiment is not always binary. Fine grained variants predict a star rating from one to five, and aspect based analysis separates opinions about different features, so a review might love the battery yet hate the screen of the same phone.

Key idea

Sentiment analysis labels the emotional tone of text, and context aware models handle negation and sarcasm that simple lexicons miss.

Check yourself

Answer to earn rating on the learn ladder.

1. Why do lexicon based methods struggle with not good?

2. What does aspect based sentiment analysis do?

3. Why do learned models beat fixed word scores?