Skip to content

Transparent AI for insurance pricing: Predicts premiums and explains "why" using SHAP and natural language summaries.

License

Notifications You must be signed in to change notification settings

Symfa-Inc/insurance-pricing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insurance Pricing Logo

💰 Insurance Premium Pricing

Python 3.13 TypeScript FastAPI Next.js scikit-learn SHAP Docker

ML service for predicting insurance premiums based on customer input data with explainability (feature importance, SHAP) and executive summary for the user.

🔗 Live Demo: insurance-pricing-demo.symfa.com

📋 Overview

This project demonstrates a transparent approach to insurance pricing using machine learning. Based on the US Health Insurance Dataset from Kaggle, the system predicts premiums while prioritizing explainability. Instead of a black-box output, it provides a detailed breakdown of how individual customer factors—such as age, BMI, and region—drive the calculated cost, helping business users understand the "why" behind every price.

🎯 Problem Statement

The goal is to build a predictive model that estimates insurance premiums based on customer characteristics, providing:

  • Accurate premium predictions based on customer attributes
  • Explainability via feature importance and SHAP values
  • Executive summary generation in human-readable language
  • Interactive parameter adjustment with real-time updates

📁 Project Structure

insurance-pricing/
├── backend/                        # 🐍 Python Backend (UV workspace member)
│   ├── src/insurance_pricing/      # FastAPI application
│   │   ├── __init__.py
│   │   └── main.py                 # API endpoints
│   ├── models/                     # Trained ML model artifacts
│   ├── notebooks/                  # Jupyter notebooks (EDA, experiments)
│   ├── scripts/                    # Training & preprocessing scripts
│   ├── data/                       # Datasets
│   │   └── source.csv
│   └── pyproject.toml              # Backend dependencies
│
├── frontend/                       # ⚛️ Next.js Frontend
│   ├── src/app/
│   │   ├── layout.tsx
│   │   ├── page.tsx
│   │   └── globals.css
│   └── package.json
│
├── pyproject.toml                  # UV workspace definition
├── uv.lock                         # Lockfile
├── .pre-commit-config.yaml         # Code quality hooks
└── README.md

📊 Dataset

The dataset contains health insurance records with the following features:

Customer Demographics

Feature Description
age Age of the primary beneficiary
sex Gender (male/female)
bmi Body mass index
children Number of dependents covered
smoker Smoking status (yes/no)
region Residential area in the US

Target Variable

Feature Description
charges Target - Individual medical costs billed by insurance

🛠️ Tech Stack

Backend

  • Python 3.13+
  • FastAPI - Modern, high-performance web framework
  • Pydantic - Data validation
  • uvicorn - ASGI server

Frontend

  • Next.js 16 - React framework with SSR
  • TypeScript - Type-safe JavaScript
  • Tailwind CSS 4 - Utility-first CSS framework
  • React 19

ML & Data Science

  • pandas - Data manipulation
  • scikit-learn - Machine learning
  • SHAP - Model explainability

Development

  • uv - Fast Python package manager
  • pnpm - Fast Node.js package manager
  • pre-commit - Git hooks for code quality
  • ruff - Linter and formatter
  • mypy - Static type checker

🚀 Getting Started

Prerequisites

  • Python 3.13+
  • Node.js 20+
  • pnpm (fast and efficient Node.js package manager)
  • uv (recommended for Python)

Installation

  1. Clone the repository:

    git clone https://github.com/Symfa-Inc/insurance-pricing.git
    cd insurance-pricing
  2. Install Python dependencies:

    uv sync
  3. Install frontend dependencies:

    cd frontend
    pnpm install

Running the Application

Backend (FastAPI):

uv run uvicorn insurance_pricing.main:app --reload

API will be available at: http://localhost:8000 API docs at: http://localhost:8000/docs

Frontend (Next.js):

cd frontend
pnpm dev

Frontend will be available at: http://localhost:3000

🔗 References

About

Transparent AI for insurance pricing: Predicts premiums and explains "why" using SHAP and natural language summaries.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •