MLOps Deployment of a scoring model in production
Python, Machine Learning, MLOps, MLflow, LightGBM, XGBoost, Scikit-learn, Credit Scoring, Optuna, Feature Engineering
Deployment and Monitoring of a Scoring Model (MLOps)
Overview
This project implements the entire production cycle of a Machine Learning model, from its exposure via an API to its monitoring in production. The objective is to transform a previously developed scoring model into a robust, testable, containerized, and automatically deployable service.
The project applies MLOps best practices to ensure the quality, reproducibility, and maintainability of a Machine Learning system in production.
Objectives
- Deploy a scoring model as an API.
- Containerize the application with Docker.
- Automate testing and deployment via a CI/CD pipeline.
- Implement a monitoring and Data Drift detection system.
- Optimize inference performance.
- Document the entire solution.
Demonstrated Skills
ML API Development
- Creation of a REST API with FastAPI (or Gradio).
- Single model loading at startup.
- Input data validation.
- Error handling.
- Automatic documentation via Swagger/OpenAPI.
Automated Tests
- Unit tests with Pytest.
- Error case validation:
- missing values
- incorrect types
- out-of-bounds values
- API stability verification.
Containerization
- Creation of a Docker image.
- Reproducible environment.
- Simplified deployment across different environments.
CI/CD
Full automation with GitHub Actions:
- dependency installation
- test execution
- Docker build
- automatic deployment
- secret management
ML Monitoring
Collection of production metrics:
- response time
- inference time
- score distribution
- error rate
- structured logs
- model inputs / outputs
Data Drift Detection
Automatic analysis of production data to detect:
- input variable drift
- prediction evolution
- statistical anomalies
- potential model degradation
Tools used:
- Evidently AI
- Streamlit dashboards
Performance Optimization
Performance analysis through profiling:
- bottleneck identification
- inference time optimization
- latency improvement
- performance impact validation
Architecture
GitHub
│
▼
GitHub Actions
│
┌───────────┴───────────┐
│ │
▼ ▼
Pytest Build Docker
│ │
└───────────┬───────────┘
▼
Deployment
│
▼
FastAPI API
│
Model Loading
│
┌─────────┴─────────┐
▼ ▼
Predictions JSON Logging
│
▼
Log Storage
│
▼
Monitoring & Data Drift
Technical Stack
Machine Learning
- Scikit-Learn
- MLflow
API
- FastAPI
- Swagger / OpenAPI
Tests
- Pytest
Containerization
- Docker
CI/CD
- GitHub Actions
Monitoring
- Evidently AI
- Streamlit
Versioning
- Git
- GitHub
Applied MLOps Best Practices
- Code versioning
- Clean Git history
- Automated tests
- Continuous deployment
- Containerization
- Documentation
- Input validation
- Production monitoring
- Data Drift detection
- Performance optimization
- Environment reproducibility
Results
Upon completion of this project, the model is capable of:
- providing predictions via a REST API;
- being automatically deployed thanks to a CI/CD pipeline;
- being executed in a Docker container;
- being supervised through monitoring metrics;
- automatically detecting data drift;
- being optimized and profiled to reduce inference times.
Acquired MLOps Skills
- Deployment of Machine Learning models
- Development of prediction APIs
- Docker
- GitHub Actions
- Automated tests
- ML model monitoring
- Structured logging
- Data Drift detection
- Performance optimization
- Industrialization of a Machine Learning project