A deep learning NLP project that classifies product reviews as positive or negative using an LSTM network, trained on Amazon's Fine Food Reviews dataset.
- Raw dataset: 887,000+ Amazon Fine Food Reviews (
Score,Text,Summary) - Labeling: reviews with a score of 4–5 are labeled positive; 1–3 are labeled negative
- Class balancing: downsampled to a balanced set of 600,000+ samples to remove label skew
- Train/Val/Test split: 80/10/10 across 620,000+ samples
- Keep only the relevant columns (
Score,Text,Summary) - Drop rows with missing text
- Convert numeric score to binary sentiment label
- Balance the dataset across both classes
- Tokenize text with a 10,000-word vocabulary
- Pad/truncate sequences to 200 tokens
- Embedding layer → LSTM layer(s) → Dense output (sigmoid) for binary classification
- Framework: TensorFlow / Keras
| Metric | Score |
|---|---|
| Test Accuracy | 89.25% |
| F1-Score | 89.1% |
Full precision/recall/F1 breakdown available via classification_report in the notebook. The best-performing model checkpoint is saved during training.
Python · TensorFlow · Keras · Pandas · NumPy · Scikit-learn
pip install -r requirements.txtDataset auto-downloads via kagglehub (snap/amazon-fine-food-reviews) when the notebook is run.
- Compare against a transformer-based baseline (e.g., DistilBERT)
- Add attention layer to the LSTM for interpretability
- Deploy as a lightweight sentiment-scoring API