This project predicts whether an Amazon product review is positive or negative and generates a concise summary of that review using machine learning and NLP.
- Single Review Mode: Predict sentiment and generate a summary for one review.
- Batch Upload Mode: Upload a CSV with a Text column and receive predictions and summaries for every row.
- Model and Dataset Dashboard: View model performance metrics and visualizations (e.g., sentiment distribution, pie chart, word clouds).
- Automated Visualizations: Sentiment distribution, review length histograms, and word clouds for positive and negative reviews.
| Layer | Choice |
|---|---|
| Data Prep | pandas, nltk (stopword removal & cleaning) |
| Vectorizer | TfidfVectorizer (1–3-gram, 10,000 features) |
| Classifier | Voting Ensemble (Logistic Regression + Random Forest + XGBoost) |
| Summary Model | Hugging Face API (facebook/bart-large-cnn) |
| UI | Streamlit |
| Visuals | matplotlib, seaborn, wordcloud |
The pre-trained model is required to run the project. Follow these steps to set it up:
- Navigate to the
models/directory. - Extract the
sentiment_model.zipfile to getsentiment_model.joblib. - Ensure the extracted file is located in the
models/directory.
You can now proceed with running the project.
-
Clone the repository
git clone <repo-url> cd sentiment-summarizer-project
-
Install dependencies
pip install -r requirements.txt
-
Download NLTK corpora
import nltk nltk.download("punkt") nltk.download("stopwords")
-
Run the Streamlit app
streamlit run webApp/app.py
sentiment-summarizer-project/
├── data/ # Raw dataset(s)
│ ├── Reviews.csv
│ └── test_batch_reviews.csv
├── models/ # Saved TF-IDF & classifier
│ ├── tfidf_vectorizer.joblib
│ ├── sentiment_model.zip # To be unzipped
│ ├── classification_report.csv
│ └── confusion_matrix.png
├── visualizations/ # PNG plots generated by data_analysis.py
│ ├── sentiment_distribution.png
│ ├── review_length_distribution.png
│ ├── positive_wordcloud.png
│ └── negative_wordcloud.png
├── webApp/
│ └── app.py # Streamlit UI
├── src/
│ ├── train_model.py # Training + saving models
│ ├── data_analysis.py # Generates visualizations
│ ├── predict_analyze.py # Prediction logic
│ ├── config.py # Centralized configuration
│ └── utils.py # Utility functions
├── notebooks/ # Optional EDA notebooks
│ └── eda_basic.ipynb
├── requirements.txt # Dependencies
└── README.md # Project documentation
- Enter/paste a review in the Single Review tab.
- Click Analyze to see:
- Predicted sentiment (+ probability scores)
- Auto-generated summary
- Prepare a CSV with a
Textcolumn. - Upload it in the Batch Upload tab.
- Download the results with predictions and summaries.
A sample file (test_batch_reviews.csv) is included for testing.
Run src/data_analysis.py to generate:
- Sentiment distribution plots
- Word clouds for positive and negative reviews
- Review length histograms
The generated plots will be saved in the visualizations/ directory.
- Anish Laddha