Product review sentiment analysis
Classify product reviews as positive, negative or neutral, first with classic ML and then with a pretrained transformer.
Beginnerโฑ 6โ10 hours๐ช 7 stepsPythonscikit-learnHugging Face (optional)
What you'll learn
- โText cleaning and tokenisation
- โBaseline vs transformer models
- โError analysis
What you'll build
- โCleaned review dataset
- โTF-IDF + logistic regression baseline
- โPretrained transformer comparison
- โDashboard of sentiment over time
Step-by-step guide
- 1
Data
A public product review dataset with star ratings; map 1โ2 stars to negative, 3 neutral, 4โ5 positive.
- 2
Clean
Lower-case, remove URLs and HTML; keep negations like "not".
- 3
Baseline
TfidfVectorizer + LogisticRegression; macro F1 score because classes are imbalanced.
- 4
Transformer
from transformers import pipeline; pipeline("sentiment-analysis") on the test set; compare F1 and speed.
- 5
Error analysis
Read 30 mistakes: sarcasm, mixed reviews, spelling. Write what you found.
- 6
Aspect words
Find the most common nouns in negative reviews (delivery, battery, size).
- 7
Present
A Streamlit page: paste a review, see sentiment; plus a chart of sentiment by month.
๐ Make it stand out
- +Fine-tune a small transformer (DistilBERT)
- +Hinglish reviews
- +Aspect-based sentiment