Coursera/IBM Supervised Learning: Regression
By: Jonathan Vasquez
Tags: IBM, Flatiron School, Data Science, Linear Regression, Coursera

Health insurance is a type of insurance product that specifically guarantees the health costs or care of the insurance members if they fall ill or have an accident. Broadly speaking, there are two types of treatments offered by insurance companies, in-patient and out-patient treatment.

However, for the Coursera/IBM project my main objective was to utilize the following Kaggle Dataset and create a model that focused on both predicting the insurances charges as well as being able to address the magnitude of the features, hence interpretability. For context, the GitHub will be hyperlinked and it has a PDF report attached as well as the working notebook, which contains code/visuals, and the CSV file.

As aforementioned, the data provided from Kaggle, referenced above, was tidy. Thus, no cleaning was needed. Furthermore, many factors that affect how much you pay for health insurance are not within your control. Nonetheless, it’s good to have an understanding of what they are. Here are some factors that affect how much health insurance premiums cost:

age: Age of primary beneficiary.

Age of primary beneficiary. sex: Insurance contractor gender: Female or Male.

Insurance contractor gender: Female or Male. bmi: Body mass index, providing an understanding of body, weights that are relatively high or low relative to height, objective index of body weight (kg / m ^ 2) using the ratio of height to weight, ideally 18.5 to 24.9.

Body mass index, providing an understanding of body, weights that are relatively high or low relative to height, objective index of body weight (kg / m ^ 2) using the ratio of height to weight, ideally 18.5 to 24.9. children: Number of children covered by health insurance / Number of dependents.

Number of children covered by health insurance / Number of dependents. smoker: Insurance beneficiary smokes: Yes or No.

Insurance beneficiary smokes: Yes or No. region: The beneficiary’s residential area in the US: Northeast, Southeast, Southwest, or Northwest.

To provide context, data from the actual dataset.

Moreover, in terms of feature engineering:

Applied the natural log to the right skewed distribution of charges graph.

Looked at the charges by region.

Looked at sex, smoking, and having children by region.

Analyzed medical charges by age, bmi, and children according to the smoking factor.

Converted objects labels (Sex, Smoker, and Region) into categorical.

Converted category labels (Sex, Smoker, and Region) into numerical using LabelEncoder.

Furthermore, I created four linear regression models; a simple linear regression as a baseline, an OLS linear regression, a linear regression with 3rd degree added polynomial effects, and a linear regression using a Ridge and Lasso regularization.

The baseline linear regression model resulted in a R² Train Score: 0.7417 & R² Test Score: 0.7833 .

. The OLS model resulted in a R² Train Score: 0.7123 & R² Test Score: 0.7570 .

. The Ridge model resulted in a R² Train Score: 0.7417 & R² Test Score: 0.7833 .

. The Lasso model resulted in a R² Train Score: 0.7417 & R² Test Score: 0.7833 .

. The 3rd degree Polynomial model resulted in a R² Train Score: 0.8415 & R² Test Score: 0.8690.

Thus, the best regression model was the 3rd degree Polynomial Regression model with an R² test score of 0.8670. The 1st degree polynomial regression was an under fit model, high bias and low variance. While the 3rd degree polynomial regression was an overfit model, low bias and high variance. Moreover, the Training Root Mean Squared Error: 4781.9091 & the Testing Root Mean Squared Error: 4508.7727.

In conclusion smoking is the greatest factor that affects medical cost charges, followed by children and bmi, respectively. Moreover, the Polynomial Regression model turned out to be the best model. In order to further analyze this data I would like to implement different machine learning models such as; Logistic Regression and Random Forest. Moreover, I would like to gather more information from these beneficiaries if possible.