Gregory Friedman The Greg Wide Web on the name →

Sentiment, Four Ways

Four models walk into a review

A lexicon full of rules, a logistic regression over n-grams, a weighted ensemble of the two, and a fine-tuned transformer, all asked the same question: is this review happy? The first two run live in this page and score whatever you type; the other two are recorded on a fixed gallery of trick sentences. Rebuilt from coursework for the Essex CE807 text-analytics module; the full story is in the write-up. Nothing you type leaves the page.

Model A · Lexicon + rules live

positive compound +0.64

scored words

  • puddle +1.4flipped
  • quiet +1.8

Model B · Hashed n-gram LR live

positive p(positive) = 0.76

strongest n-grams

  • no +0.30
  • runs +0.26
  • quiet +0.24
  • no puddle +0.18
  • whisper quiet +0.13
  • whisper +0.08
Plate I Two models score your sentence as you type. Model A is a compact lexicon scorer in the style of VADER: each word carries a valence, negators flip it, intensifiers boost it, and the word chips show every rule that fired. Model B is a logistic regression over hashed unigrams and bigrams, trained offline on a synthetic corpus; its chips show the n-grams that pulled the verdict. The gallery beneath compares all four models on ten sentences, two per error mode; the try button hands any row to the live pair.

VADER lexicon (unsupervised)

accuracy 0.830
macro-F1 0.704

TF-IDF + logistic regression

accuracy 0.874
macro-F1 0.830

Weighted ensemble (α = 0.78)

accuracy 0.901
macro-F1 0.857

Fine-tuned DistilBERT

accuracy 0.923
macro-F1 0.881

Validation-split results from the CE807 coursework runs (n = 700, 79.6% positive), quoted as reported there. Accuracy flatters everyone: the all-positive baseline already scores 0.796, which is why macro-F1, which weighs the scarce negative class equally, is the honest column.

Plate II What the extra machinery buys: accuracy and macro-F1 for the four models on the coursework validation split, quoted as reported there. The dashed line is the all-positive baseline; the distance beyond it, not the raw accuracy, is each model's real achievement.

Why the lexicon falls for sarcasm, why n-grams lose track of negation, what the transformer buys and what it costs: the case study works through every row of the gallery. The lexicon, the training script, and the weights all live in this site's repository.

Keys on this page

A figure's keys are its own: they answer once the figure has focus, so tab to it or click it first. Esc closes this sheet.