Sentiment Classification of Amazon Product Reviews Using Machine Learning: A Comparative Study of Logistic Regression, Naive Bayes, and SVM
Sentiment Classification of Amazon Product Reviews Using Machine Learning: A Comparative Study of Logistic Regression, Naive Bayes, and SVM
Shaik.Afreen
Abstract
Online consumer reviews constitute a rich but unstructured source of product feedback; harnessing them at scale requires robust, automated sentiment analysis. This study benchmarks three classical supervised learning algorithms — Logistic Regression, Naive Bayes, and Support Vector Machine (SVM) — on the Amazon Fine Food Reviews dataset, one of the largest publicly available corpora of consumer food opinions. After rigorous preprocessing, the usable corpus was reduced from 568,454 to 363,825 records, retaining text and polarity labels. A TF-IDF vectorization pipeline with negation-aware n-gram features was applied before model training. SVM delivered the highest classification accuracy of 93.75%, followed by Logistic Regression at 91.08% and Naive Bayes at 90.01%, all substantially exceeding the majority-class baseline of 84.17%. Five-fold cross-validation confirmed Logistic Regression's stability (mean = 91.08%, std = 0.06%). Detailed analysis of the confusion matrix and per-class metrics revealed a pronounced class imbalance (84% positive reviews), which suppresses precision on the negative class to 0.66 while maintaining recall at 0.90. Feature importance analysis identified negation n-grams — including 'not bitter', 'not disappointed', and 'not recommend' — as the most discriminative predictors in both sentiment directions. Error analysis of false positives and false negatives suggests that mixed-sentiment and comparative language remain the primary failure modes. These findings demonstrate that SVM with n-gram features is highly effective for food review sentiment classification and establish clear directions for improvement through class-balancing techniques and transformer-based architectures.
Keywords: Sentiment Analysis, Amazon Food Reviews, Support Vector Machine, Logistic Regression, Naive Bayes, TF-IDF, Natural Language Processing, Text Classification, Class Imbalance, N-gram Features