Skip to content

About

This Repo contains the 4th Task for my FreeCodeCamp Course

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

💸 Health Insurance Cost Predictor

A machine learning project using Linear Regression to predict health insurance expenses based on personal and lifestyle data. Built using TensorFlow 2.x and trained on real-world data from insurance.csv.


📁 Dataset

The dataset contains the following features:

  • age – Age of primary beneficiary
  • sex – Gender (male, female)
  • bmi – Body mass index
  • children – Number of dependents
  • smoker – Whether the person smokes (yes, no)
  • region – Residential area in the US (northeast, northwest, etc.)
  • expenses – Medical costs billed by health insurance

🔄 Preprocessing

  • One-hot encoding applied to:
    • sex, smoker, and region (with drop_first=True to avoid dummy variable trap)
  • expenses column popped as target variable
  • Train-test split: 80% training / 20% testing
  • StandardScaler used to normalize feature columns

🧠 Model Architecture

Built using TensorFlow Keras Sequential API:

  • Dense(256) → ReLU
  • Dropout(0.1)
  • Dense(128) → ReLU
  • Dropout(0.1)
  • Dense(64) → ReLU
  • Dense(1) → Output layer (regression)

Compiled with:

  • Loss: Mean Squared Error (MSE)
  • Optimizer: Adam
  • Metrics: Mean Absolute Error (MAE)

EarlyStopping used to prevent overfitting.


📊 Results

  • Evaluated on unseen test set
  • Achieved MAE < 3500, passing the freeCodeCamp challenge ✅

Example output:


🚀 How to Run

  1. Load the notebook in Google Colab
  2. Run all cells (training will auto-start)
  3. Final cell evaluates the model and displays predictions vs true values on a scatter plot

🧾 Challenge Objective

Train a regression model that can predict healthcare costs within a $3500 error margin on new, unseen data. Mission accomplished.


About

This Repo contains the 4th Task for my FreeCodeCamp Course

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages