WORK / APPLIED ML RESEARCH / SENTIMENT ANALYSIS

CONTEXT-AWARE NLP

Sentiment
Analysis.

From a published comparison of BERT and traditional models to a reproducible pipeline and live Streamlit product that treats sentiment and irony as separate classification tasks.

CONTEXT-AWARE CLASSIFICATION02 TASKS
“Great. Another update that broke everything.”
01 · SENTIMENTNegative · Neutral · PositiveThree-way contextual classification
02 · IRONYNot irony · IronyIndependent binary classification

Irony is surfaced as evidence. It does not automatically reverse sentiment.

PROJECT TYPEIndependent ML project
RESEARCHCo-authored publication
CLEAN DATA56,554 sentiment rows
LIVE PRODUCTStreamlit application
QUESTION
DATA
EXPERIMENT
SYSTEM
FINDINGS

— PROJECT SNAPSHOT

60-SECOND READ
01 / THE PROBLEM

A single accuracy score can hide uneven sentiment-model behavior and costly class-level errors

02 / MY ROLE

Research design, data preparation, modeling and evaluation

03 / KEY DECISION

Compare accuracy with macro F1 and inspect errors before choosing a model

04 / PRODUCT

Interactive Streamlit sentiment classifier paired with a reproducible sentiment-and-irony pipeline

05 / EVIDENCE

56,554 cleaned sentiment rows, independent splits, a co-authored publication and a deployed application

06 / STATUS

Published research · live Streamlit product

01

Question

The project began with a model-selection question, then evolved into a stricter question about evidence.

RESEARCH QUESTION

When does contextual language understanding justify the additional cost of a transformer over a fast TF-IDF baseline?

TRADITIONAL

Patterns in terms and n-grams

Fast, inspectable and practical for clearer language.

TRANSFORMER

Meaning from both directions

Better suited to negation, ambiguity and context-dependent phrasing.

02

Data

The current implementation starts with an auditable cleaning pass instead of treating the downloaded rows as ground truth.

74,682source rows
56,554clean sentiment rows
45,175training rows
5,826validation rows
5,553test rows
4,601TweetEval irony rows
12,990

irrelevant labels excluded

2,774

exact duplicates removed

111

conflicting texts isolated

710

missing texts removed

01NORMALISE

Decode HTML and remove invisible characters

02MASK

Replace URLs and mentions with stable tokens

03PRESERVE

Keep case, emojis, punctuation, hashtags and negation

04SPLIT

Group by source ID to prevent related-text leakage

03

Experiment

Every model is evaluated on the same independent test split, with macro F1 used to expose uneven class behavior.

CURRENT REPRODUCIBLE BASELINESIndependent test · 5,553 rows
Naive Bayes
65.4% accuracy63.7% macro F1
Logistic Regression
65.0% accuracy64.3% macro F1
Linear SVM
63.6% accuracy62.9% macro F1
BEST ACCURACY65.4%

Naive Bayes

It produced the highest headline accuracy, helped by strong recall on negative examples.

BEST MACRO F164.3%

Logistic Regression

Its more balanced class performance made it the strongest traditional baseline overall.

HARDEST CLASS42.7%

Neutral recall

Naive Bayes frequently pulled neutral language toward a stronger sentiment class.

— PUBLISHED BENCHMARK

Context improved the paper’s reported comparison.

The RACCAI study evaluated IMDb reviews and Twitter sentiment. These are paper-reported results, not outputs from the newer repository artifacts.

BERT89%IMDb88%Twitter
Hybrid BERT91%IMDb90%Twitter
LSTM85%IMDb83%Twitter
SVM82%IMDb80%Twitter
Logistic Regression80%IMDb79%Twitter
Naive Bayes78%IMDb76%Twitter
04

System

The implementation turns the comparison into a reproducible training system with explicit task boundaries.

01INPUT

Raw social text

02CLEAN

Conservative normalization

03REPRESENT

TF-IDF or tokenizer

04CLASSIFY

Baseline or DistilBERT

05EVALUATE

Accuracy + macro/weighted F1

SEPARATE TASK HEADS

SENTIMENTNegative · Neutral · Positive
IRONYNot irony · Irony

Detecting irony adds context; it does not mechanically invert the sentiment output.

TRANSFORMER CONFIGURATION

MODELDistilBERT base uncased
SEQUENCE128 tokens
LEARNING RATE2e-5
TRAINING2 epochs · batch 8 · accumulation 2
SELECTIONBest validation macro F1
IMPLEMENTED WITHPythonpandasscikit-learnPyTorchHugging Face TransformersTweetEvalpytest

— LIVE PRODUCT

Test the classification workflow in Streamlit.

The deployed interface turns the modeling work into a usable product: enter text, run sentiment classification and inspect the prediction without setting up the repository locally.

Live deployment · Streamlit Community Cloud · the service may take a moment to wake after inactivity.
REPRODUCIBLE SOURCECleaning, grouped splits, baseline artifacts and transformer training
05

Findings

The useful conclusion is not that one model always wins; it is knowing which evidence should drive the choice.

01

Headline accuracy can hide class imbalance

Macro F1 exposed that neutral language remained harder than the overall score suggested.

02

Context is valuable when language is genuinely contextual

The published benchmark favoured BERT on longer reviews and short, ambiguous social text.

03

Efficiency remains a product constraint

Traditional models train quickly, are easier to inspect and remain useful when latency or compute matters.

04

Irony deserves its own uncertainty signal

A separate irony task is safer than automatically flipping a sentiment prediction.

LIMITATIONS

What the current evidence does not claim.

  • The newer transformer training path exists, but no current transformer metric artifact is presented as a completed result.
  • Performance can shift across topics, writing styles and time periods.
  • Sarcasm and irony remain probabilistic signals, not deterministic corrections.
  • The published benchmark and the reproducible repository use different evaluation contexts.
PUBLISHED RESEARCH

— RACCAI 2024 · AIP 2025

Comparative Study of BERT vs. Traditional Machine Learning Models for Sentiment Analysis

Co-authored research published in AIP Conference Proceedings 3343. Read the complete paper here or open its official publication record.

— THE NEXT DECISION

Have a complex problem
worth simplifying?

I’m exploring entry-level Associate Product Manager and AI Product opportunities where I can combine user understanding, analytical thinking and technical execution.

SIGNAL
PROBLEM
DECISION
PRODUCT
LEARNING
APPLYING