Skip to content

g24ai1002/mlops-linear-regression

Repository files navigation

Name: Shubham Verma
Roll Number: G24AI1002
Course: MLOps
Instructor: Dr. Pratik Mazumder


📌 Project Overview

This repository implements a complete MLOps pipeline using LinearRegression from scikit-learn on the California Housing dataset. It includes:

  • Model training
  • Manual quantization (8-bit)
  • Inference and evaluation
  • Docker containerization
  • CI/CD integration with GitHub Actions
  • Automated testing

📂 Repository Structure

.
├── src/
│   ├── train.py           # Train Linear Regression model
│   ├── quantize.py        # Quantize model coefficients
│   ├── predict.py         # Make predictions
│   └── utils.py           # Shared functions
├── tests/
│   └── test_train.py      # Unit tests using pytest
├── .github/
│   └── workflows/
│       └── ci.yml         # GitHub Actions workflow
├── model.joblib           # Pretrained model (generated via train.py)
├── requirements.txt       # Project dependencies
├── Dockerfile             # Container setup
├── .gitignore             # Ignore cache/artifact files
└── README.md              # Project documentation

🚀 How to Run

1. Setup Environment

python -m venv venv
venv\Scripts\activate        # On Windows
pip install -r requirements.txt

2. Train the Model

python src/train.py

3. Quantize the Model

python src/quantize.py

4. Predict

python src/predict.py

5. Run Unit Tests

pytest

6. Build & Run with Docker

docker build -t housing_model .
docker run --rm housing_model

🧪 CI/CD Workflow

GitHub Actions runs on every push to main, consisting of:

  1. test suite: runs unit tests using pytest
  2. train and quantize: trains model and performs quantization
  3. build and test container: builds Docker image and verifies predictions

All jobs must pass for the workflow to succeed.


📷 Output

  • R2 Score & MSE
R2 score   MSE
  • Sample Vs Actual Prediction
Sample Vs Actual Prediction

🔐 Notes & Constraints

  • Only LinearRegression is used.
  • No hardcoded values.
  • Code is modularized and organized.
  • Only the main branch exists.
  • CI/CD is implemented using GitHub Actions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published