Skip to content

onlynayan/meal-forecast-mlops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meal Forecast MLOps

End-to-end MLOps system for forecasting daily and monthly meal expenses using historical meal and cost data.

🚀 Overview

This project implements a complete MLOps pipeline:

  • Data preprocessing & feature engineering
  • Model training & experiment logging (MLflow)
  • Model versioning via Model Registry
  • FastAPI-based model serving
  • Automatic model updates by pulling the Production version
  • Optional containerized deployment (Docker/Render/Railway)

🧱 Architecture

                        ┌────────────────────────┐
                        │  train_with_mlflow.py   │
                        │   (Training Script)     │
                        └─────────────┬───────────┘
                                      │ Logs Metrics + Artifacts
                                      ▼
                            🧠 MLflow @ DagsHub
                         - Experiments Dashboard
                         - Metrics / Parameters
                         - Model Versions
                         - Model Registry (Production / Staging)
                                      │
                                      ▼
                        ┌────────────────────────┐
                        │     FastAPI Service     │
                        │  Loads PRODUCTION Model │
                        └─────────────┬───────────┘
                                      │
                                      ▼
                         ✅ Returned Predictions (API)

📂 Project Structure

meal-forecast-mlops/
│
├── app/
│   ├── main.py              # FastAPI application (serves model)
│   ├── schemas.py           # Response models
│   └── plotting.py          # (Optional) Forecast graph utilities
│
├── data/
│   └── expenses.csv         # Example dataset
│
├── mlops/
│   └── train_with_mlflow.py # Train + log + register model
│
├── infra/mlflow/
│   ├── Dockerfile           # Deploy the API
│   └── render-start.sh      # Server start script
│
├── requirements.txt
├── .env.example
└── README.md

🔧 Installation

git clone https://github.com/onlynayan/meal-forecast-mlops
cd meal-forecast-mlops

python -m venv .venv
source .venv/Scripts/activate        # Windows
# or
source .venv/bin/activate           # Mac/Linux

pip install -r requirements.txt

⚙️ Environment Variables

Create .env file based on .env.example:

MLFLOW_TRACKING_URI=https://dagshub.com/<username>/<repo>.mlflow
MLFLOW_TRACKING_USERNAME=<your-username>
MLFLOW_TRACKING_PASSWORD=<mlflow-token>

MODEL_NAME=meal_forecast_model
DATA_CSV=./data/expenses.csv

🧠 Train & Log Model

python mlops/train_with_mlflow.py

After training:

→ Visit MLflow UI to view metrics & artifact runs
→ Promote model to Production in Model Registry

https://dagshub.com/<username>/<repo>.mlflow

🌍 Run FastAPI Server

uvicorn app.main:app --reload

API Endpoints

Method Endpoint Description
GET / API running status
GET /health Check model & dataset load
GET /predict/month?year=2025&month=2 Forecast full month
/plots/forecast?year=2025&month=2 Download forecast graph

Example request:

GET http://127.0.0.1:8000/predict/month?year=2025&month=2

🐳 Docker Deployment (Optional)

docker build -t meal-forecast-api -f infra/mlflow/Dockerfile .
docker run -p 8000:8000 meal-forecast-api

✨ Key Advantage

When you promote a new model version to Production, the FastAPI service automatically starts using the new modelno re-deploy needed.

This is real MLOps.


👨‍💻 Author

Nayan Das
GitHub: https://github.com/onlynayan

About

End-to-end MLOps pipeline for forecasting meal expenses using MLflow, model registry and FastAPI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors