A production-ready Machine Learning API for predicting California house prices, deployed using modern MLOps practices.
This project demonstrates a complete end-to-end MLOps pipeline including:
- ✅ Machine Learning model training and evaluation
- ✅ REST API with FastAPI
- ✅ Docker containerization
- ✅ CI/CD with GitHub Actions
- ✅ GitOps deployment with ArgoCD
- ✅ Kubernetes orchestration (K3s)
- ✅ Cloud hosting (Hetzner)
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Developer │────▶│ GitHub Repo │────▶│ GitHub Actions │
│ (Push Code) │ │ (my-ml-model) │ │ (CI/CD) │
└─────────────────┘ └──────────────────┘ └────────┬────────┘
│
▼
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Kubernetes │◀────│ ArgoCD │◀────│ GitOps Repo │
│ (K3s Cloud) │ │ (Auto-Sync) │ │ (my-mlops-gitops)│
└────────┬────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ ML API Pod │
│ (FastAPI) │
└─────────────────┘
| Metric | Value |
|---|---|
| Algorithm | Random Forest Regressor |
| R² Score | 0.80 (80% variance explained) |
| MAE | $33,291 |
| Training Samples | 16,512 |
| Test Samples | 4,128 |
| Service | URL |
|---|---|
| Live App (demo) | https://ml-house-price.duckdns.org/ |
| ArgoCD Dashboard | http://37.27.8.233:30082 |
curl http://37.27.8.233:32199/healthResponse:
{"status": "healthy", "model_loaded": true, "service": "House Price Prediction API"}curl http://37.27.8.233:32199/model/infocurl -X POST http://37.27.8.233:32199/predict \
-H "Content-Type: application/json" \
-d '{
"median_income": 8.3252,
"house_age": 41,
"avg_rooms": 6.98,
"avg_bedrooms": 1.02,
"population": 322,
"avg_occupancy": 2.55,
"latitude": 37.88,
"longitude": -122.23
}'Response:
{
"predicted_price": 423567.01,
"model_version": "1.0.0",
"features_used": {...}
}| Category | Technology |
|---|---|
| ML Framework | scikit-learn, pandas, numpy |
| API Framework | FastAPI, Pydantic, Uvicorn |
| Containerization | Docker |
| CI/CD | GitHub Actions |
| Container Registry | GitHub Container Registry (GHCR) |
| Orchestration | Kubernetes (K3s) |
| GitOps | ArgoCD |
| Cloud Provider | Hetzner Cloud |
my-ml-model-repo/
├── model.py # FastAPI application
├── train_model.py # Model training script
├── model.pkl # Trained ML model
├── model_metadata.json # Model metrics & metadata
├── requirements.txt # Python dependencies
├── Dockerfile # Container definition
└── .github/
└── workflows/
└── main.yml # CI/CD pipeline
The pipeline automatically triggers on push to main branch:
- Build - Docker image built with model and API
- Push - Image pushed to GitHub Container Registry
- Update - GitOps repo updated with new image tag
- Deploy - ArgoCD detects change and deploys to Kubernetes
# Clone repository
git clone https://github.com/Tomo1912/my-ml-model-repo.git
cd my-ml-model-repo
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Train model (optional - pre-trained model included)
python train_model.py
# Run API locally
uvicorn model:app --reload --host 0.0.0.0 --port 8000The model is trained on the California Housing Dataset from scikit-learn, which contains:
- 20,640 samples of California housing data
- 8 features including median income, house age, location, etc.
- Target: Median house value (in $100,000s)