A Python-based analytical tool that uses RoBERTa for sentiment analysis, K-Means clustering for automated product categorization, and BART for abstractive review summarization.
- Sentiment Analysis: Classifies customer reviews (Positive / Neutral / Negative) using a fine-tuned RoBERTa model.
- Product Clustering: Groups products into logical categories using sentence embeddings + K-Means, then labels each cluster with GPT-4o-mini.
- Visualization: Interactive dashboard (Chart.js) showing sentiment distribution, category rankings, and sentiment trends over time.
- AI Market Reports (notebook-only, not wired into the UI): Generates "best"/"worst" product summaries using
facebook/bart-large-cnn, producing cohesive write-ups instead of raw quote lists.
app.py # Flask application / API routes
services/
data_processor.py # Upload validation & cleaning
ml_engine.py # Sentiment, clustering, and category labeling
models/sentiment_model/ # Fine-tuned RoBERTa checkpoint (not included, see below)
notebooks/ # Model training & experimentation
classifier_full_dataset.ipynb
clustering.ipynb
review_summarization.ipynb
templates/, static/ # Dashboard UI
-
Clone the repository
git clone https://github.com/keirialaa/customer_reviews.git cd customer_reviews -
Create a virtual environment and install dependencies
python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt # runtime only # or, to also run the notebooks / tests: pip install -r requirements-dev.txt
-
Configure environment variables
Copy the example file and fill in your own keys:
cp .env.example .env
Variable Required Purpose FLASK_SECRET_KEYYes Flask session signing key. Any random string works locally. OPENAI_API_KEYYes Used by GPT-4o-mini to generate cluster category labels. HF_TOKENOnly for the notebooks Hugging Face token used when downloading/pushing models in notebooks/. -
Provide the sentiment model
models/sentiment_model/is not committed to the repo (the checkpoint is ~500MB). To get it locally, either:- Run
notebooks/classifier_full_dataset.ipynbend-to-end, which fine-tunes RoBERTa and saves the checkpoint tomodels/sentiment_model/, or - Point
MODEL_PATHinservices/ml_engine.pyat a Hugging Face Hub model ID instead of a local path.
- Run
-
Run the application
export FLASK_APP=app.py flask runThen open
http://127.0.0.1:5000, upload a CSV with at leastproduct_nameandreview_textcolumns, and view the dashboard.
pip install -r requirements-dev.txt
pytestMIT — see LICENSE.