Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis on Amazon Fine Food Reviews (LSTM)

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.

Overview

  • 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

Preprocessing Pipeline

  1. Keep only the relevant columns (Score, Text, Summary)
  2. Drop rows with missing text
  3. Convert numeric score to binary sentiment label
  4. Balance the dataset across both classes
  5. Tokenize text with a 10,000-word vocabulary
  6. Pad/truncate sequences to 200 tokens

Model

  • Embedding layer → LSTM layer(s) → Dense output (sigmoid) for binary classification
  • Framework: TensorFlow / Keras

Results

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.

Tech Stack

Python · TensorFlow · Keras · Pandas · NumPy · Scikit-learn

Setup

pip install -r requirements.txt

Dataset auto-downloads via kagglehub (snap/amazon-fine-food-reviews) when the notebook is run.

Possible Extensions

  • Compare against a transformer-based baseline (e.g., DistilBERT)
  • Add attention layer to the LSTM for interpretability
  • Deploy as a lightweight sentiment-scoring API

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages