AI · Automation 2026 Completed

MedCost — Honest Medical Insurance Cost Predictor

A rebuild of a popular insurance-cost predictor that fixes its data leakage, then adds calibrated 90% prediction ranges, what-if scenarios and a written evaluation report.

Built by Redoan Uzzaman, Full-Stack Developer & AI Engineer.

MedCost — Honest Medical Insurance Cost Predictor

Overview

MedCost estimates annual medical insurance charges from age, BMI, number of children and smoking status. It started as an audit of a widely shared open-source predictor and ended as a stronger, more honest replacement.

The problem

The original dataset has 2,772 rows, but only 1,337 of them are unique. After a random split, most test rows also appear in the training data, so the reported accuracy partly measures memorisation. Scored on the same untouched set of unique test rows, MedCost reaches an R² of 0.928 and an MAE of $1,154. The original Random Forest gets 0.884 and $2,458 on that set.

How it works

Duplicates are removed before splitting, and a 20% holdout (stratified by smoker) is set aside before any model is chosen. Eight models are compared with repeated 5-fold cross-validation. The final model is gradient boosting with a Huber loss and an engineered smoker × obesity feature. Sex and region are dropped from pricing because removing them cost less than one cross-validation standard deviation of accuracy.

Each prediction comes with a 90% range from split conformal prediction, calibrated separately for smokers and non-smokers. The app also shows what-if scenarios (quit smoking, reach BMI 25, ten years older), an age curve, and warnings for inputs outside the training range.

The FastAPI service exposes a JSON prediction API and serves a written project report with interactive figures and a PDF export. The model artifacts are committed, so the Docker image needs no training step.

Key Features

  • Leakage audit of the original project, with a fair side-by-side comparison
  • 8-model comparison with repeated 5-fold cross-validation
  • Gradient boosting with Huber loss and a smoker × obesity feature
  • Split-conformal 90% prediction ranges per smoker group
  • What-if scenarios, age curve and out-of-range input warnings
  • Interactive project report with PDF export
  • REST API and Dockerised deployment

Tech Stack

  • Python
  • scikit-learn
  • FastAPI
  • Conformal Prediction
  • JavaScript
  • Docker
  • Playwright
  • pytest

Want something like this built?

Redoan Uzzaman takes on AI, automation and full-stack projects for clients worldwide.