Skip to content

Repository files navigation

🎯 Product Review Sentiment Analysis & Spam Detection

Python Version Streamlit App Flask API SQLite

A modern, full-stack machine learning application designed to extract actionable insights from product reviews. The application automatically filters out deceptive spam reviews using a Random Forest classifier, performs VADER sentiment analysis, and visualizes insights across dual dashboards.


🚀 Key Features

  • 🧠 Machine Learning Spam Filter: Leverages a trained Random Forest Classifier with TF-IDF vectorization to identify and exclude fake/deceptive reviews (achieving 85.94% accuracy).
  • 📈 Dual Dashboards:
    • Streamlit Application: A serverless, database-driven dashboard connected to a local SQLite database, featuring interactive charts, word clouds, and key-phrase extractors.
    • Static Web UI: A clean HTML5/CSS3/JavaScript frontend using Chart.js to visualize statistics directly from user-uploaded CSV/Excel datasets.
  • ⚡ VADER Sentiment Engine: Analyzes review texts and classifies them as Positive, Neutral, or Negative on the fly.
  • 💾 Serverless SQLite Storage: Fully migrated database backend requiring zero configuration or running server instances.
  • 🔄 Automatic Data Fallback: Smart data ingestion that automatically sets up a default dataset if no custom CSV is provided.

📂 Project Structure

  • app.py - Main Streamlit dashboard code.
  • database_storage.py - Ingestion script that cleans data, predicts spam, and populates the SQLite database.
  • load_data.py - Core helper to load CSV files with automatic fallback.
  • train_spam_detector.py - Scikit-Learn script to train and save the Random Forest classifier.
  • export_to_json.py - Exporter that pushes SQLite records into a JSON file for the static web dashboard.
  • backend/ - Flask API server providing endpoints for dataset upload, WordClouds, and sentiment summaries.
  • website/ - Clean frontend interface built with HTML, CSS, JavaScript, and Chart.js.

⚙️ Setup & Installation

1. Initialize Virtual Environment & Install Dependencies

First, clone the repository, navigate into the directory, and set up a Python virtual environment:

# Create a virtual environment
python -m venv .venv

# Activate the virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate

# Install required packages
pip install -r requirements.txt

2. Train the Spam Classifier

Train the Scikit-learn model and save the classifier files:

python train_spam_detector.py

3. Load Dataset & Populate Database

Initialize the database table and ingest reviews (falls back to spam_data/deceptive-opinion.csv automatically if no custom dataset is in data/):

python database_storage.py

🖥️ Running the Applications

Option A: Launch the Streamlit Dashboard (Database-Driven)

Start the Streamlit application:

streamlit run app.py

👉 Open http://localhost:8501 in your browser.

Option B: Launch the Flask Backend & Web UI

Start the API server:

# Start Flask API
python backend/api_server.py

👉 Double-click or open website/index.html in any web browser, and upload a CSV/Excel file of reviews to analyze them instantly!

About

A full-stack NLP and machine learning application that uses a Random Forest classifier to filter review spam and VADER to analyze sentiment, featuring interactive Streamlit and Flask/HTML5 dashboards.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages