Skip to content

charan-jilagam/sentiment-mlops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Sentiment Analysis API - MLOps Project

A production-ready sentiment analysis API built with FastAPI, Hugging Face Transformers, and deployed using modern MLOps practices.

🎯 Features

  • ✅ Real-time sentiment analysis using DistilBERT model
  • ✅ RESTful API with FastAPI
  • ✅ Dockerized application
  • ✅ CI/CD pipeline with GitHub Actions
  • ✅ Deployed on Render (free tier)
  • ✅ Interactive API documentation (Swagger UI)

🛠️ Tech Stack

  • Backend: Python 3.10, FastAPI
  • ML Model: Hugging Face Transformers (DistilBERT)
  • Containerization: Docker
  • CI/CD: GitHub Actions
  • Deployment: Render.com

🚀 Live Demo

API URL: https://your-app-name.onrender.com

Endpoints:

  • GET / - Welcome message
  • GET /health - Health check
  • POST /predict - Sentiment prediction
  • GET /docs - Interactive API documentation
  • GET /examples - Example texts to test

📦 Local Setup

Prerequisites

  • Python 3.10+
  • Docker (optional)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/sentiment-mlops.git
cd sentiment-mlops
  1. Install dependencies:
pip install -r app/requirements.txt
  1. Run the application:
cd app
python main.py
  1. Open browser: http://localhost:8000/docs

Docker Setup

# Build image
docker build -t sentiment-mlops .

# Run container
docker run -p 8000:8000 sentiment-mlops

🧪 API Usage

cURL Example:

curl -X POST "http://localhost:8000/predict" \
     -H "Content-Type: application/json" \
     -d '{"text": "I love machine learning!"}'

Python Example:

import requests

response = requests.post(
    "http://localhost:8000/predict",
    json={"text": "This MLOps project is awesome!"}
)
print(response.json())

Response Format:

{
  "text": "I love machine learning!",
  "sentiment": "POSITIVE",
  "confidence": 0.9998,
  "model": "distilbert-base-uncased-finetuned-sst-2"
}

📊 MLOps Pipeline

  1. Code Push → GitHub
  2. Automated Testing → GitHub Actions
  3. Docker Build → Containerization
  4. Deployment → Render.com
  5. Live API → Production

🎓 Skills Demonstrated

  • Machine Learning model deployment
  • API development with FastAPI
  • Docker containerization
  • CI/CD pipeline implementation
  • Cloud deployment (Render)
  • Git version control
  • RESTful API design

📈 Future Improvements

  • Add unit tests with pytest
  • Implement API rate limiting
  • Add authentication
  • Support batch predictions
  • Add model monitoring
  • Implement A/B testing for models

👨‍💻 Author

Your Name

📝 License

MIT License


⭐ If you found this project helpful, please give it a star!

About

Sentiment Analysis API - MLOps Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors