Skip to content

FR34KY-CODER/FreeCodeCamp-LinearRegressionTask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

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

Watchers

Forks

Releases

No releases published

Packages

No packages published