A production-level Machine Learning application that performs sentiment analysis on YouTube comments using FastAPI, Streamlit, Docker, Redis, Explainable AI, and automated testing.
- Sentiment Prediction
- Positive / Negative / Neutral Classification
- FastAPI REST API
- Streamlit Frontend
- Explainable AI Support
- Redis Rate Limiting
- Dockerized Application
- Automated API Testing with Pytest
- Logging System
- CI/CD Ready Structure
- Scalable Project Architecture
- Scikit-learn
- TF-IDF Vectorizer
- Multinomial Naive Bayes
- FastAPI
- Uvicorn
- Redis
- SlowAPI
- Streamlit
- Docker
- Docker Compose
- GitHub Actions
- Pytest
- FastAPI TestClient
Youtube_comment_sentiment_Analysis/
│
├── .github/
│ └── workflows/
│ └── ci.yml
│
├── backend/
│ │
│ ├── model/
│ │ ├── sentiment_model.pkl
│ │ └── label_encoder.pkl
│ │
│ ├── logs/
│ │ └── app.log
│ │
│ ├── tests/
│ │ ├── __init__.py
│ │ ├── test_api.py
│ │ ├── test_input.py
│ │ └── test_rate_limiting.py
│ │
│ ├── __init__.py
│ ├── app.py
│ ├── logger.py
│ ├── Dockerfile
│ └── requirements.txt
│
├── frontend/
│ ├── streamlit_app.py
│ ├── Dockerfile
│ └── requirements2.txt
│
├── data/
│ └── YoutubeCommentsDataset.csv
│
├── notebook/
│ └── youtube-comments-sentiment.ipynb
│
├── .gitignore
├── docker-compose.yml
├── README.md
└── pytest.ini
- Text Cleaning
- TF-IDF Vectorization
- Model Training
- Sentiment Prediction
- Explainable AI Visualization
| Label | Sentiment |
|---|---|
| 0 | Negative |
| 1 | Positive |
| 2 | Neutral |
git clone <repository_url>
cd Youtube_comment_sentiment_Analysispython -m venv myenvActivate environment:
myenv\Scripts\activatesource myenv/bin/activatepip install -r backend/requirements.txtpip install -r frontend/requirements2.txtuvicorn backend.app:app --reloadBackend runs on:
http://127.0.0.1:8000
streamlit run frontend/streamlit_app.pyFrontend runs on:
http://localhost:8501
{
"comment": "This video is amazing"
}{
"comment": "This video is amazing",
"Sentiment": "Positive"
}Provides prediction explanation for user comments.
Run Redis using Docker:
docker run -d --name redis-container -p 6379:6379 redisVerify container:
docker psdocker build -t sentiment-backend ./backenddocker build -t sentiment-frontend ./frontendRun complete application:
docker-compose up --buildpytest -vExpected Result:
================ 4 passed =================
API uses Redis-based rate limiting.
Example:
@limiter.limit("5/minute")Application logs are stored in:
backend/logs/app.log
GitHub Actions workflow included for:
- Automated Testing
- Build Validation
- Deployment Ready Setup
Workflow File:
.github/workflows/ci.yml
- Transformer-based Models
- HuggingFace Integration
- Kubernetes Deployment
- Monitoring with Prometheus
- Grafana Dashboard
- JWT Authentication
- Cloud Deployment
Sangita Bera
This project is licensed under the MIT License.