Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment & Summary Analyzer for Amazon Reviews

Description

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.

Features

  • 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.

Tech Stack

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

Setup

Extract the Model File

The pre-trained model is required to run the project. Follow these steps to set it up:

  1. Navigate to the models/ directory.
  2. Extract the sentiment_model.zip file to get sentiment_model.joblib.
  3. Ensure the extracted file is located in the models/ directory.

You can now proceed with running the project.

  1. Clone the repository

    git clone <repo-url>
    cd sentiment-summarizer-project
  2. Install dependencies

    pip install -r requirements.txt
  3. Download NLTK corpora

    import nltk
    nltk.download("punkt")
    nltk.download("stopwords")
  4. Run the Streamlit app

    streamlit run webApp/app.py

Directory Layout

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

Usage

Single Review

  1. Enter/paste a review in the Single Review tab.
  2. Click Analyze to see:
    • Predicted sentiment (+ probability scores)
    • Auto-generated summary

Batch Upload

  1. Prepare a CSV with a Text column.
  2. Upload it in the Batch Upload tab.
  3. Download the results with predictions and summaries.

A sample file (test_batch_reviews.csv) is included for testing.

Visualizations

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.


Authors

  • Anish Laddha

About

A Python-based tool for sentiment analysis and text summarization using machine learning and Hugging Face APIs.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages