Skip to content

A production-ready sentiment analysis application powered by DistilBERT that analyzes text sentiment in real-time with an interactive dashboard.

Notifications You must be signed in to change notification settings

Emart29/sentiment-analysis-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎭 Real-Time Sentiment Analysis Dashboard

Python Streamlit Transformers License

A production-ready sentiment analysis application powered by DistilBERT that analyzes text sentiment in real-time with an interactive dashboard.

🌟 Features

  • Real-Time Analysis: Instant sentiment prediction using state-of-the-art AI
  • Batch Processing: Upload CSV files with thousands of texts
  • Interactive Dashboard: Beautiful visualizations with Plotly
  • Historical Data: SQLite database stores all analyses
  • Export Functionality: Download results as CSV
  • Production Ready: Error handling, logging, and validation

🎯 Use Cases

  • Customer Feedback Analysis: Analyze reviews and support tickets
  • Social Media Monitoring: Track brand sentiment on Twitter/Reddit
  • Market Research: Understand customer opinions at scale
  • Content Moderation: Flag negative content automatically
  • Academic Research: Study sentiment patterns in text data

🏗️ Architecture

┌─────────────────┐
│   Streamlit UI  │  ← Beautiful web interface
└────────┬────────┘
         │
┌────────▼────────┐
│ SentimentAnalyzer│  ← DistilBERT model (66M params)
└────────┬────────┘
         │
┌────────▼────────┐
│  Data Handler   │  ← SQLite database operations
└────────┬────────┘
         │
┌────────▼────────┐
│    Database     │  ← Stores all results & analytics
└─────────────────┘

🚀 Quick Start

Prerequisites

  • Python 3.8 or higher
  • 8GB RAM (minimum)
  • 2GB free disk space

Installation

  1. Clone the repository
git clone https://github.com/Emart29/sentiment-analysis-dashboard.git
cd sentiment-analysis-dashboard
  1. Create virtual environment
python -m venv venv

# Windows
venv\Scripts\activate

# Mac/Linux
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt

This will download the DistilBERT model (~250MB) automatically on first run.

Running the Application

streamlit run app.py

The dashboard will open in your browser at http://localhost:8501

📖 Usage Guide

1. Single Text Analysis

Navigate to "Single Text Analysis" and:

  • Enter or paste your text
  • Click "Analyze Sentiment"
  • View results with confidence scores

2. Batch Analysis

Two options available:

Option A: CSV Upload

  • Prepare CSV with a column named text, comment, review, or message
  • Upload via "Batch Analysis""Upload CSV"
  • Click "Analyze All"

Option B: Manual Entry

  • Go to "Batch Analysis""Manual Entry"
  • Enter texts (one per line)
  • Click "Analyze All"

3. Analytics Dashboard

View comprehensive analytics:

  • Sentiment distribution (pie chart)
  • Confidence score histogram
  • Daily trends (line chart)
  • Recent analyses table
  • Export data to CSV

🧠 Model Details

Model: distilbert-base-uncased-finetuned-sst-2-english

  • Architecture: DistilBERT (distilled BERT)
  • Parameters: 66 million
  • Training Data: Stanford Sentiment Treebank (SST-2)
  • Accuracy: ~91% on SST-2 test set
  • Speed: 60% faster than BERT
  • Memory: Only 255MB

Why DistilBERT?

  • ✅ Lightweight enough for laptops
  • ✅ High accuracy (97% of BERT's performance)
  • ✅ Fast inference (~100ms per text)
  • ✅ Well-maintained by Hugging Face
  • ✅ Perfect for production use

📊 Project Structure

sentiment-analysis-dashboard/
│
├── app.py                    # Main Streamlit application
├── sentiment_analyzer.py     # DistilBERT sentiment analysis
├── data_handler.py          # SQLite database operations
├── utils.py                 # Helper functions & visualizations
├── requirements.txt         # Python dependencies
├── README.md               # This file
├── .gitignore              # Git ignore rules
│
├── data/                   # Database storage
     └── sentiment.db        # SQLite database (auto-created)

🛠️ Technical Stack

Component Technology Purpose
ML Model DistilBERT Sentiment classification
ML Framework Transformers Model loading & inference
Backend PyTorch Neural network operations
Frontend Streamlit Web dashboard
Database SQLite Data persistence
Visualization Plotly Interactive charts
Data Processing Pandas Data manipulation

⚡ Performance

Tested on Dell Latitude 5400 (i5-8th gen, 8GB RAM):

  • Single text analysis: ~150ms
  • Batch (100 texts): ~8 seconds
  • Memory usage: ~600MB
  • Database operations: <10ms per query

🔮 Future Enhancements

  • Multi-class sentiment (Very Negative, Negative, Neutral, Positive, Very Positive)
  • Real-time Twitter/Reddit API integration
  • Sentiment trend alerts via email
  • Multi-language support
  • User authentication
  • RESTful API endpoint
  • Docker containerization
  • Cloud deployment (AWS/GCP/Azure)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

Your Name

🙏 Acknowledgments

📞 Support

If you have any questions or run into issues, please:

  1. Check the Issues page
  2. Create a new issue with detailed description
  3. Contact me directly via email or LinkedIn

If you found this project helpful, please consider giving it a star!

About

A production-ready sentiment analysis application powered by DistilBERT that analyzes text sentiment in real-time with an interactive dashboard.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages