A supervised machine learning project that predicts medical insurance charges using the Medical Insurance Cost Dataset from Kaggle.
The project benchmarks 10 regression models, ranging from simple linear regression to advanced gradient boosting ensembles, while maintaining consistent preprocessing pipelines and systematic hyperparameter tuning.
Insurance charges depend on multiple demographic and lifestyle factors such as age, BMI, smoking habits, and family size.
This project aims to:
- Predict individual medical insurance costs.
- Compare the performance of multiple regression algorithms.
- Analyze the impact of feature engineering on model performance.
- Demonstrate that domain knowledge can significantly improve simpler models.
Medical-Insurance-Prediction/
│
├── load_data.py # Dataset loading and train/test split
├── pipeline.py # Preprocessing pipeline for linear models
├── pipeline_tree_model.py # Preprocessing pipeline for tree-based models
│
├── eda.ipynb
├── linear_regression.ipynb
├── ridgecv.ipynb
├── lasso_cv.ipynb
├── elastic_net.ipynb
├── elastic_net_grid_searchcv.ipynb
├── svm.ipynb
├── decision_trees.ipynb
├── random_forest.ipynb
├── adaboost.ipynb
├── gradient_boosting.ipynb
├── xgboost.ipynb
│
├── models/
│ ├── linear_regression_pipeline.pkl # Trained Linear Regression pipeline
│ └── xgboost_pipeline.pkl # Trained XGBoost pipeline
│
├── images/ # EDA plots, model evaluation graphs, and visualizations
│
└── README.md
- Dataset: Medical Insurance Cost Prediction Dataset
- Source: Kaggle
- Dataset Link: https://www.kaggle.com/datasets/mosapabdelghany/medical-insurance-cost-dataset
- Target Variable:
charges
- Age
- Sex
- BMI
- Children
- Smoker
- Region
- Linear Regression
- Ridge Regression (RidgeCV)
- Lasso Regression (LassoCV)
- Elastic Net (CV)
- Elastic Net (GridSearchCV)
- Support Vector Regression (SVR)
- Decision Tree Regressor
- Random Forest Regressor
- AdaBoost Regressor
- Gradient Boosting Regressor
- XGBoost Regressor
One of the major findings of this project is that domain-specific interaction features dramatically improved linear model performance.
smoker_bmi = smoker × BMICaptures the increased impact of BMI among smokers.
smoker_obese = smoker AND BMI >= 30Represents smokers who are also clinically obese.
These features model the real-world compounding effect of smoking and obesity on medical insurance costs.
| Model | Test MAE | Test R² |
|---|---|---|
| XGBoost | ~1416 | ~0.8629 |
| Gradient Boosting | ~1611 | ~0.8595 |
| SVM | ~1724 | ~0.8596 |
| Decision Tree | ~1875 | ~0.8527 |
| Random Forest | ~1970 | ~0.8603 |
| Linear Regression | ~2391 | ~0.8690 |
| Ridge CV | ~2391 | ~0.8690 |
| Elastic Net (GridSearchCV) | ~2391 | ~0.8690 |
| Lasso CV | ~2400 | ~0.8689 |
| Elastic Net CV | ~2486 | ~0.8679 |
| AdaBoost | ~2551 | ~0.8576 |
-
Carefully engineered interaction features allowed linear regression to outperform several ensemble methods in R².
-
XGBoost achieved the lowest Mean Absolute Error (MAE), making it the best model for minimizing prediction error.
-
The data naturally separates into three distinct groups:
- Non-smokers
- Smokers with normal BMI
- Smokers with high BMI
-
These groups explain the structured residual patterns observed across nearly every model.
Evaluation Metric: Models were trained and tuned using cross-validation with
neg_mean_absolute_errorbecause target column is having outliers.
You need Kaggle API and kagglehub to run this.
pip install -r requirements.txtClone the repository:
git clone https://github.com/YugamdeepGoyal/PremiumPulse.gitNavigate to the project:
cd PremiumPulseOpen any notebook.
The dataset will be downloaded automatically using kagglehub.
- Exploratory Data Analysis (EDA)
- Feature Engineering
- Scikit-learn Pipelines
- Column Transformers
- Hyperparameter Tuning
- GridSearchCV
- Cross Validation
- Model Evaluation
- Regression Analysis
- Ensemble Learning
- XGBoost
- Machine Learning Workflow
This project is licensed under the MIT License.
This project is intended for educational and portfolio purposes.


