Insurance companies provide coverage for expenses incurred by policyholders due to damages to health or property. These policies include medical bills, house insurance, motor vehicle insurance, and fire insurance, along with financial losses such as loss of income. Traditional methods of premium calculation are time-consuming and struggle to capture complex data interactions.
In this project, the goal is to build a machine learning model using XGBoost Regressor to predict healthcare expenses based on features such as age, BMI, smoking, etc. The aim is to help the insurance firm establish accurate premium rates and maximize profits.
The dataset contains historical records of 1338 insured customers with the following columns:
- Age: Age of the primary beneficiary.
- Sex: Gender of the primary beneficiary.
- BMI: Body mass index of the primary beneficiary.
- Children: Number of children the primary beneficiary has.
- Smoker: Whether the primary beneficiary smokes.
- Region: The primary beneficiary's residential area in the US.
- Charges: Individual medical costs billed by health insurance.
- Language:
Python
- Libraries:
pandas
,numpy
,matplotlib
,plotly
,statsmodels
,sklearn
,xgboost
,skopt
-
Exploratory Data Analysis (EDA)
- Distributions
- Univariate Analysis
- Bivariate Analysis
- Correlation
- Pearson Correlation
- Chi-squared Tests
- ANOVA
-
Build
- Linear regression assumptions
- Data preprocessing
- Model training
- Model evaluation (RMSE)
-
Improve on the baseline linear model
- Introduction to a non-linear model - XGBoost
- Data preprocessing
- Using Sklearn's
Pipeline
to optimize the model training process - Model evaluation (RMSE)
- Comparison to the baseline model
-
Presenting the results to non-technical stakeholders
- The
lib
folder contains the original ipython notebook. - The
ml_pipeline
folder contains functions organized into different Python files.engine.py
calls these functions to run the steps and print the results. - The
requirements.txt
file lists the required libraries with their respective versions.
-
Create a Python environment using the command 'python3 -m venv myenv'.
-
Activate the environment by running the command 'myenv\Scripts\activate.bat'.
-
Install the required packages using the command 'pip install -r requirements.txt'.
-
Run the project's main script 'engine.py' with the command 'python3 engine.py'.