{"id":31287895,"url":"https://github.com/mrkunalsharma/fraud-detection-mlops","last_synced_at":"2026-05-03T15:35:44.837Z","repository":{"id":315786190,"uuid":"1060822221","full_name":"MrKunalSharma/fraud-detection-mlops","owner":"MrKunalSharma","description":"🚀 Production-ready fraud detection system with 99.95% accuracy, real-time API, and comprehensive monitoring","archived":false,"fork":false,"pushed_at":"2025-09-20T19:10:05.000Z","size":54,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-20T19:10:29.219Z","etag":null,"topics":["docker","fastapi","fraud-detection","grafana","machine-learning","mlops","prometheus","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrKunalSharma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-20T17:00:14.000Z","updated_at":"2025-09-20T19:10:09.000Z","dependencies_parsed_at":"2025-09-20T19:10:35.458Z","dependency_job_id":"eac13485-dfe1-4f9f-a7ad-c963165bd125","html_url":"https://github.com/MrKunalSharma/fraud-detection-mlops","commit_stats":null,"previous_names":["mrkunalsharma/fraud-detection-mlops"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/MrKunalSharma/fraud-detection-mlops","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrKunalSharma%2Ffraud-detection-mlops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrKunalSharma%2Ffraud-detection-mlops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrKunalSharma%2Ffraud-detection-mlops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrKunalSharma%2Ffraud-detection-mlops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrKunalSharma","download_url":"https://codeload.github.com/MrKunalSharma/fraud-detection-mlops/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrKunalSharma%2Ffraud-detection-mlops/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276738916,"owners_count":25696023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fastapi","fraud-detection","grafana","machine-learning","mlops","prometheus","python"],"created_at":"2025-09-24T11:30:32.288Z","updated_at":"2025-09-24T11:32:20.727Z","avatar_url":"https://github.com/MrKunalSharma.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛡️ Real-time Fraud Detection System with MLOps Pipeline\n\n[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)\n[![FastAPI](https://img.shields.io/badge/FastAPI-0.104.1-green.svg)](https://fastapi.tiangolo.com/)\n[![Docker](https://img.shields.io/badge/Docker-Containerized-blue.svg)](https://www.docker.com/)\n[![Prometheus](https://img.shields.io/badge/Monitoring-Prometheus-orange.svg)](https://prometheus.io/)\n[![Live Demo](https://img.shields.io/badge/demo-live-brightgreen.svg)](https://fraud-detection-mlops-msnfh7adt5ykkr6yzbmhyv.streamlit.app/)\n[![API Status](https://img.shields.io/badge/API-online-brightgreen.svg)](https://fraud-detection-api-v5cc.onrender.com/docs)\n\nA production-ready machine learning system for real-time credit card fraud detection, featuring automated model training, API deployment, and comprehensive monitoring.\n\n\u003e **🎯 Perfect for**: Data Scientists, ML Engineers, DevOps Engineers, and anyone interested in MLOps best practices\n\n## 🌟 Key Features\n\n- **Real-time Fraud Detection**: REST API endpoint for instant fraud prediction\n- **MLOps Pipeline**: Automated data preprocessing, model training, and evaluation\n- **Model Comparison**: Evaluates Random Forest, Logistic Regression, and Decision Tree\n- **Production Monitoring**: Prometheus metrics and Grafana dashboards\n- **Containerized Deployment**: Docker Compose for easy deployment\n- **High Performance**: Sub-100ms prediction latency\n\n\n## 🚀 Live Demo\n\n### Try it Now!\n🎯 **[Fraud Detection System Demo](https://fraud-detection-mlops-msnfh7adt5ykkr6yzbmhyv.streamlit.app/)**\n\n### API Endpoints\n📚 **[Interactive API Docs](https://fraud-detection-api-v5cc.onrender.com/docs)**  \n🔍 **[Health Check](https://fraud-detection-api-v5cc.onrender.com/health)**\n\n\n## 🚀 Quick Start\n\n### Prerequisites\n- Python 3.10+\n- Docker Desktop\n- 8GB RAM minimum\n\n### Installation\n**Option 1: Try the Live Demo** \n🚀 Visit [https://fraud-detection-mlops-msnfh7adt5ykkr6yzbmhyv.streamlit.app/](https://fraud-detection-mlops-msnfh7adt5ykkr6yzbmhyv.streamlit.app/)\n\n**Option 2: Run Locally**\n1. **Clone the repository**\n\n```bash\ngit clone https://github.com/MrKunalSharma/fraud-detection-mlops.git\ncd fraud-detection-mlops\n```\n\n2. **Run with Docker Compose**\n\n```bash\ndocker-compose up --build\n```\n\n3. **Access the services**\n- 📚 **API Documentation**: [http://localhost:8000/docs](http://localhost:8000/docs)\n- 📊 **Prometheus Metrics**: [http://localhost:9090](http://localhost:9090)\n- 📈 **Grafana Dashboard**: [http://localhost:3000](http://localhost:3000) (admin/admin)\n\n## 💻 Local Development\n\n1. **Create virtual environment**\n\n```bash\npython -m venv venv\nvenv\\Scripts\\activate  # Windows\nsource venv/bin/activate  # Linux/Mac\n```\n\n2. **Install dependencies**\n\n```bash\npip install -r requirements.txt\n```\n\n3. **Download dataset**\n\n```bash\npython download_data.py\n```\n\n4. **Train models**\n\n```bash\npython -m src.data_preprocessing\npython -m src.model_training\n```\n\n5. **Run API locally**\n\n```bash\npython run_api.py\n```\n\n## 📊 Model Performance\n\n| Model | Accuracy | Precision | Recall | F1-Score | ROC-AUC |\n|-------|----------|-----------|--------|----------|---------|\n| **Random Forest** | 99.95% | 95.12% | 82.93% | 88.61% | 0.9146 |\n| **Logistic Regression** | 99.91% | 91.67% | 73.33% | 81.48% | 0.8666 |\n| **Decision Tree** | 99.89% | 86.21% | 83.33% | 84.75% | 0.9165 |\n\n\u003e **🏆 Winner**: Random Forest achieves the best overall performance with 99.95% accuracy and 88.61% F1-Score\n\n## 🔄 API Usage\n\n### Health Check\n\n```bash\ncurl http://localhost:8000/health\n```\n\n### Fraud Prediction\n\n```bash\ncurl -X POST \"http://localhost:8000/predict\" \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\n       \"Time\": 0,\n       \"V1\": -1.359807,\n       \"V2\": -0.072781,\n       \"V3\": 2.536347,\n       \"V4\": 1.378155,\n       \"V5\": -0.338321,\n       \"V6\": 0.462388,\n       \"V7\": 0.239599,\n       \"V8\": 0.098698,\n       \"V9\": 0.363787,\n       \"V10\": 0.090794,\n       \"V11\": -0.551600,\n       \"V12\": -0.617801,\n       \"V13\": -0.991390,\n       \"V14\": -0.311169,\n       \"V15\": 1.468177,\n       \"V16\": -0.470401,\n       \"V17\": 0.207971,\n       \"V18\": 0.025791,\n       \"V19\": 0.403993,\n       \"V20\": 0.251412,\n       \"V21\": -0.018307,\n       \"V22\": 0.277838,\n       \"V23\": -0.110474,\n       \"V24\": 0.066928,\n       \"V25\": 0.128539,\n       \"V26\": -0.189115,\n       \"V27\": 0.133558,\n       \"V28\": -0.021053,\n       \"Amount\": 149.62\n     }'\n```\n\n### Response\n\n```json\n{\n  \"prediction\": 0,\n  \"probability\": 0.02,\n  \"risk_level\": \"Low\",\n  \"message\": \"Transaction seems legitimate\"\n}\n```\n\n## 📈 Monitoring \u0026 Metrics\n\n### 📊 Tracked Metrics\n- **Prediction Analytics**: Total predictions count by type (fraud/legitimate)\n- **Performance**: Prediction latency histogram and response times\n- **Reliability**: API request success/error rates\n- **Model Health**: Real-time model performance metrics\n\n### 📈 Grafana Dashboards\nAccess comprehensive visualizations:\n- **Real-time fraud detection rate**\n- **Transaction risk distribution**\n- **API response times**\n- **System health metrics**\n- **A/B testing results**\n\n## 🗂️ Project Structure\n\n```\nfraud-detection-mlops/\n├── src/\n│   ├── config.py              # Configuration settings\n│   ├── data_preprocessing.py  # Data pipeline\n│   ├── model_training.py      # Model training logic\n│   ├── model_serving.py       # FastAPI application\n│   └── monitoring.py          # Metrics tracking\n├── models/                    # Trained models\n├── data/                      # Dataset storage\n├── docker/                    # Docker configurations\n├── monitoring/                # Prometheus \u0026 Grafana configs\n├── tests/                     # Unit tests\n├── requirements.txt           # Python dependencies\n├── Dockerfile                 # Container definition\n└── docker-compose.yml         # Multi-container setup\n```\n\n## 🔧 Configuration\n\nKey configurations in `src/config.py`:\n- **Model hyperparameters**: Learning rates, tree depth, regularization\n- **API settings**: Port, host, rate limiting, authentication\n- **Monitoring intervals**: Metrics collection frequency, alert thresholds\n- **Data paths**: Input/output directories, model storage locations\n\n\n## 🚀 Advanced Features\n\n### A/B Testing \u0026 Model Versioning\n- Multiple model versions deployed simultaneously\n- Traffic splitting for gradual rollouts\n- Performance comparison metrics\n- Automatic winner selection\n\n### API Authentication\n```bash\n# Include API key in requests\ncurl -X POST \"https://api-url/predict\" \\\n     -H \"X-API-Key: your-api-key\" \\\n     -H \"Content-Type: application/json\" \\\n     -d '{...}'\n```\n\n### Data Drift Detection\n- Real-time monitoring of feature distributions\n- Automatic alerts when drift detected\n- Z-score based drift calculation\n- Integrated with monitoring dashboard\n\n### Load Testing Results\n- Handles 120+ requests/second\n- 99.8% success rate under load\n- \u003c100ms average response time\n- Detailed performance documentation in `/docs/PERFORMANCE.md`\n\n### Monitoring Endpoints\n- `/metrics` - Prometheus metrics\n- `/health` - Health check\n- `/model-performance` - A/B test results\n\n\n## 📝 Key Learnings\n\nThis project demonstrates:\n- **End-to-end ML pipeline development** from data preprocessing to deployment\n- **REST API design** with FastAPI and proper error handling\n- **Containerization** with Docker and Docker Compose\n- **Production monitoring** with Prometheus/Grafana integration\n- **MLOps best practices** including CI/CD, testing, and monitoring\n- **A/B testing** for model comparison and gradual rollouts\n- **Data drift detection** for model reliability\n\n## 🤝 Contributing\n\nWe welcome contributions! Here's how to get started:\n\n1. **Fork the repository** and clone your fork\n2. **Create a feature branch** (`git checkout -b feature/AmazingFeature`)\n3. **Make your changes** and add tests if applicable\n4. **Commit your changes** (`git commit -m 'Add AmazingFeature'`)\n5. **Push to your branch** (`git push origin feature/AmazingFeature`)\n6. **Open a Pull Request** with a clear description\n\n### 🎯 Areas for Contribution\n- 🐛 Bug fixes and improvements\n- 📊 Additional model algorithms\n- 📈 Enhanced monitoring features\n- 🧪 More comprehensive tests\n- 📚 Documentation improvements\n\n## 📜 License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## 🙏 Acknowledgments\n\n- **Dataset**: [Kaggle Credit Card Fraud Detection](https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud) - High-quality anonymized credit card transactions\n- **Inspiration**: Real-world fraud detection systems and MLOps best practices\n- **Technologies**: Built with modern MLOps tools and practices\n- **Community**: Thanks to the open-source community for the amazing tools and libraries\n\n## 📧 Contact\n\n**Kunal Sharma**\n\n- LinkedIn: [https://www.linkedin.com/in/kunal-sharma-1a8457257/](https://www.linkedin.com/in/kunal-sharma-1a8457257/)\n- Email: kunalsharma13579kunals@gmail.com\n- GitHub: [https://github.com/MrKunalSharma](https://github.com/MrKunalSharma)\n- Project Link: [https://github.com/MrKunalSharma/fraud-detection-mlops](https://github.com/MrKunalSharma/fraud-detection-mlops)\n\n---\n\n⭐ **If you found this project helpful, please consider giving it a star!**\n\n[![GitHub stars](https://img.shields.io/github/stars/MrKunalSharma/fraud-detection-mlops?style=social)](https://github.com/MrKunalSharma/fraud-detection-mlops)\n[![GitHub forks](https://img.shields.io/github/forks/MrKunalSharma/fraud-detection-mlops?style=social)](https://github.com/MrKunalSharma/fraud-detection-mlops)\n[![GitHub watchers](https://img.shields.io/github/watchers/MrKunalSharma/fraud-detection-mlops?style=social)](https://github.com/MrKunalSharma/fraud-detection-mlops)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkunalsharma%2Ffraud-detection-mlops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrkunalsharma%2Ffraud-detection-mlops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkunalsharma%2Ffraud-detection-mlops/lists"}