NLP · Web scraping · Classification
Customer Review Sentiment Analysis
An NLP pipeline that scrapes product reviews, cleans the text and classifies sentiment, so negative feedback surfaces automatically instead of being buried in thousands of reviews.
- 96%accuracy
- 0.92macro F1
- 1,468unique reviews
- 7models compared
The problem
Product and marketing teams receive thousands of reviews and can't read them all. They need to know which products get negative feedback, quickly enough to act.
The data
2,318 scraped e-commerce reviews across five categories, reduced to 1,468 unique reviews after removing duplicates and empty text.
Approach
Scraping
requests + BeautifulSoup across shoes, skincare, gadgets and fitness categories.
Text cleaning
Lower-casing, punctuation and stop-word removal, tokenisation and lemmatisation with NLTK.
Labelling
No human labels existed, so sentiment was labelled with VADER and cross-checked with TextBlob.
Modelling
TF-IDF features, SMOTE on training data only; Logistic Regression, Naive Bayes, trees, boosting, LSTM and GRU compared.
Deployment
A Streamlit app that classifies any review a user types.
What I found
- Negative reviews are only 17% of the data, so a model that always says 'positive' already scores 83%. I judged models on negative-class F1 instead.
- TF-IDF + Logistic Regression beat the deep-learning models; at ~1.5k reviews the LSTM/GRU never learned beyond the majority class.
| Model | Accuracy | Negative-class F1 | Macro F1 |
|---|---|---|---|
| Logistic Regression (TF-IDF) | 0.96 | 0.87 | 0.92 |
| Random Forest | 0.95 | 0.86 | 0.92 |
| Naive Bayes | 0.94 | 0.84 | 0.90 |
| Decision Tree | 0.90 | 0.76 | 0.85 |
The key insight
At this data size, the simple, explainable model is the right choice, and the right metric is the one that measures what the business needs to catch: negative reviews.
Limitations & next steps
- Labels come from VADER, so the models partly learn to reproduce it; hand-labelling a few hundred reviews would give true ground truth.
- Next: aspect-based sentiment (delivery, quality, price) and a fine-tuned transformer.