Skip to content

Repository files navigation

🚗 Vehicle Insurance Prediction

End-to-End MLOps Application

Python scikit-learn Docker AWS CI/CD License


Predicts whether a customer will purchase vehicle insurance — end-to-end, production-ready.
Full MLOps pipeline from raw data to a Dockerized Flask app deployed on AWS EC2.


🎯 Problem Statement

Insurance companies need to identify which existing health insurance customers are likely to also purchase vehicle insurance. This reduces cold outreach, improves conversion rates, and optimises premium pricing strategy.

This application takes customer profile inputs and predicts the likelihood of insurance purchase using a trained classification model.


🏗️ System Architecture

Raw Data
   │
   ▼
Data Ingestion ──▶ Data Validation ──▶ Data Transformation
                                               │
                                               ▼
                                       Model Training
                                               │
                                               ▼
                                       Model Evaluation
                                               │
                                               ▼
                                    Flask Web Application
                                               │
                              ┌────────────────┴────────────────┐
                              ▼                                  ▼
                         Docker Image                      CI/CD Pipeline
                              │                           (GitHub Actions)
                              ▼                                  │
                        AWS ECR Registry  ◀────────────────────-─┘
                              │
                              ▼
                         AWS EC2 Server

✨ Features

  • Binary Classification — Predicts Yes/No insurance purchase likelihood
  • Full MLOps Pipeline — Automated data ingestion → validation → transformation → training → evaluation
  • Modular Codebase — Clean src/ structure with separate components for each pipeline stage
  • Flask Web App — Simple, responsive UI for real-time predictions
  • Dockerized — Fully containerized for consistent deployment anywhere
  • CI/CD via GitHub Actions — Auto-builds Docker image and deploys to AWS EC2 on every push
  • Configurable — All parameters managed via config/ — no hardcoding

🗂️ Project Structure

vehicle-insurance-prediction/
│
├── src/
│   ├── components/         # Pipeline stages: ingestion, validation, transformation, training
│   ├── pipeline/           # Training & prediction pipeline orchestration
│   ├── entity/             # Data classes for config and artifact entities
│   └── utils/              # Common utilities
│
├── config/                 # YAML config files for all pipeline parameters
├── notebook/               # EDA and model experimentation notebooks
├── templates/              # Flask HTML templates
├── static/css/             # Frontend styling
│
├── .github/workflows/      # CI/CD pipeline (GitHub Actions → AWS EC2)
│
├── app.py                  # Flask application entry point
├── Dockerfile              # Container definition
├── setup.py                # Package setup
├── pyproject.toml          # Build config
├── requirements.txt        # Dependencies
└── README.md

🚀 Quick Start

Run Locally

1. Clone the repo

git clone https://github.com/Siddharth9o9/Vehicle-Insurance-Prediction-End-To-End-Application.git
cd Vehicle-Insurance-Prediction-End-To-End-Application

2. Create virtual environment

python -m venv venv
source venv/bin/activate        # macOS / Linux
venv\Scripts\activate           # Windows

3. Install dependencies

pip install -r requirements.txt

4. Run the training pipeline

python demo.py

5. Launch the Flask app

python app.py

Open http://localhost:5000 in your browser.


Run with Docker

# Build the image
docker build -t vehicle-insurance-prediction .

# Run the container
docker run -p 5000:5000 vehicle-insurance-prediction

🛠️ Tech Stack

Layer Technology
ML & Data Python, scikit-learn, pandas, NumPy
Experimentation Jupyter Notebook
Web App Flask, HTML/CSS
Containerization Docker
CI/CD GitHub Actions
Cloud AWS EC2, AWS ECR
Config Management YAML-based config system

🔄 MLOps Pipeline Stages

1. Data Ingestion — Loads raw dataset, splits into train/test sets, stores artifacts

2. Data Validation — Schema checks, null detection, distribution validation against expected schema

3. Data Transformation — Feature engineering, encoding, scaling — outputs a transformation artifact

4. Model Training — Trains classifier, tunes hyperparameters, saves model artifact

5. Model Evaluation — Compares new model against production baseline, promotes only if improved

6. Prediction Pipeline — Loads saved model + transformer, runs inference on new inputs from the Flask UI


⚙️ CI/CD Flow

git push ──▶ GitHub Actions triggered
                │
                ▼
           Run tests & lint
                │
                ▼
         docker build & push ──▶ AWS ECR
                                    │
                                    ▼
                            Pull & run on AWS EC2

Every push to main automatically builds a fresh Docker image, pushes it to ECR, and redeploys on the EC2 instance — zero manual steps.


📊 Model Details

Attribute Detail
Task Binary Classification
Target Will customer buy vehicle insurance? (Yes / No)
Key Features Age, Gender, Vehicle Age, Prior Damage, Prior Insurance, Premium, Sales Channel
Evaluation Metric ROC-AUC, F1-Score

📄 License

MIT — free to use, modify, and distribute.


Built with Python · scikit-learn · Flask · Docker · GitHub Actions · AWS

About

An end to end Vehicle Insurance Cost prediction application which can predict the insurance cost based on certain features. Complete MLOPS project with robust pipeline.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages