A production-ready sentiment analysis application powered by DistilBERT that analyzes text sentiment in real-time with an interactive dashboard.
- 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
- 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
┌─────────────────┐
│ Streamlit UI │ ← Beautiful web interface
└────────┬────────┘
│
┌────────▼────────┐
│ SentimentAnalyzer│ ← DistilBERT model (66M params)
└────────┬────────┘
│
┌────────▼────────┐
│ Data Handler │ ← SQLite database operations
└────────┬────────┘
│
┌────────▼────────┐
│ Database │ ← Stores all results & analytics
└─────────────────┘
- Python 3.8 or higher
- 8GB RAM (minimum)
- 2GB free disk space
- Clone the repository
git clone https://github.com/Emart29/sentiment-analysis-dashboard.git
cd sentiment-analysis-dashboard- Create virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate- Install dependencies
pip install -r requirements.txtThis will download the DistilBERT model (~250MB) automatically on first run.
streamlit run app.pyThe dashboard will open in your browser at http://localhost:8501
Navigate to "Single Text Analysis" and:
- Enter or paste your text
- Click "Analyze Sentiment"
- View results with confidence scores
Two options available:
Option A: CSV Upload
- Prepare CSV with a column named
text,comment,review, ormessage - 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"
View comprehensive analytics:
- Sentiment distribution (pie chart)
- Confidence score histogram
- Daily trends (line chart)
- Recent analyses table
- Export data to CSV
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
- ✅ 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
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)
| 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 |
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
- 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)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: Emart29
- LinkedIn: Emmanuel Nwanguma
- Hugging Face for the Transformers library
- Streamlit for the amazing framework
- Stanford NLP for the SST-2 dataset
If you have any questions or run into issues, please:
- Check the Issues page
- Create a new issue with detailed description
- Contact me directly via email or LinkedIn
⭐ If you found this project helpful, please consider giving it a star! ⭐