This project performs binary sentiment classification on the Amazon Fine Food Reviews dataset (https://snap.stanford.edu/data/web-FineFoods.html), comparing whether a review's summary or full text is more effective for identifying positive and negative sentiment.
Dataset
- Original reviews: 568,454
- Users: 256,059
- Products: 74,258
- Period: October 1999–October 2012
- Positive: scores 4–5
- Negative: scores 1–2
- Neutral/mixed: score 3 excluded
- Remove nonessential metadata (
ProductId,UserId,ProfileName, helpfulness fields,Time). - Convert ratings into positive/negative labels.
- Clean text:
- Remove numbers and punctuation
- Convert to lowercase
- Tokenize
- Stem words
- Experiment with stopword removal
- Balance the dataset to 164,074 reviews:
- 82,037 positive
- 82,037 negative
- Build a bag-of-words vocabulary and generate length-normalized TF-IDF feature vectors.
- Train and evaluate classifiers using 5-fold cross-validation.
- Multinomial Naive Bayes
- Logistic Regression
- Support Vector Machine (linear kernel)
Three preprocessing variants were evaluated:
- Keep all stopwords
- Remove the stopwords provided in standard 127-word NLTK stopword list
- Create a customized 120-word list and remove the stopwords
The customized list retains seven sentiment-bearing words that were removed from the standard stopword list:
but, above, below, no, not, too, very
- Review Text outperformed Review Summary for sentiment classification
- Linear SVM achieved the highest accuracy: 93.134% on Review Text without removing any stopwords
- Multinomial Naive Bayes produced the lowest accuracy among the three models
- Retaining sentiment-bearing words such as
not,no,but,too, andveryproduced results close to retaining all stopwords
- Python 2.7
- NLTK 3.1 — tokenization, stemming, stopword and special-character processing
- scikit-learn — classifiers and model evaluation
- pandas — data handling
- NumPy / SciPy — mathematical and data computation