
#Sentiment Lab — Twitter Sentiment Classification Baseline
A TF-IDF + Multinomial Naive Bayes baseline for classifying tweets about gaming brands and platforms (Borderlands, Call of Duty, Nvidia, FIFA, and dozens of others) as Positive or Negative sentiment.
#What It Does
Takes the Twitter Entity Sentiment dataset — tweets labeled by brand/entity and sentiment class — and trains a classic ML baseline: clean the text, vectorize with TF-IDF, classify with Naive Bayes. This page reports what was actually built and measured, not an aspirational production pipeline.
#What Was Built
- Data: A random 500-row sample from
twitter_training.csv(the full dataset is much larger), reduced to 302 rows after dropping a missing review and restricting to the Positive and Negative classes only — Neutral and Irrelevant were excluded, so this is a binary classifier, not a full 4-class sentiment model - Preprocessing: NLTK tokenization (
RegexpTokenizer) with stopword removal - Features: TF-IDF vectorization (302 samples × 1,661 features)
- Model:
MultinomialNB, trained on an 80/20 train/test split (241 train / 61 test)
#Results (Real, Measured)
On the 61-sample held-out test set:
| Class | Precision | Recall | F1 |
|---|---|---|---|
| Negative | 0.65 | 0.67 | 0.66 |
| Positive | 0.59 | 0.57 | 0.58 |
Overall accuracy: 62%. That's a modest result for a binary classification task — meaningfully above the ~54% majority-class baseline for this split, but not a strong classifier. It's reported as what it is: a first baseline on a small sample, not a finished system.
#What's Incomplete (Named Honestly)
- The validation set was never evaluated.
twitter_validation.csvis loaded and filtered to match the binary setup, but the trained model is never actually run against it — there's no validation accuracy to report, despite validation data being present in the repo. - Trained on ~300 rows, not the full dataset. The 500-row sample (down to 302 after class filtering) is a small fraction of the available training data. A production baseline would train on the full set.
- Neutral and Irrelevant classes are dropped, not handled. Real-world sentiment classification needs to deal with ambiguous and off-topic text, not just discard it.
#Solution Architecture
twitter_training.csv (full dataset)
→ Random 500-row sample → drop 1 missing review → 499 rows
→ Filter to Positive/Negative only → 302 rows
→ NLTK tokenization + stopword removal
→ TF-IDF vectorization (302 × 1,661 features)
→ 80/20 train/test split (241 / 61)
→ MultinomialNB → 62% test accuracy
(twitter_validation.csv loaded and filtered, but not yet evaluated against the model)
Key engineering decisions:
- TF-IDF + Naive Bayes as a deliberate first baseline — a fast, interpretable starting point before reaching for anything heavier. The value of a baseline is knowing what "better" needs to beat, not being the final answer.
- Binary scoping was a real simplification, and it's named as one — dropping Neutral/Irrelevant made the problem tractable for a first pass, at the direct cost of not handling two of the four real classes in the data.
#Why This Matters
A 62%-accuracy binary baseline on 302 rows isn't an impressive number on its own — but reporting it accurately, alongside exactly what wasn't finished (validation evaluation, full-dataset training, 4-class handling), is more useful than a polished-sounding page that collapses under the first follow-up question about test coverage or validation accuracy. The next real step here is finishing the validation evaluation that's already half-built in the repo.