Machine Learning with Python Projects - Linear Regression Health Costs Calculator

Tell us what’s happening:

Using a simple model with only one layer, something like

model = tf.keras.Sequential([layers.Dense(units=1)])

I get a MAE of about 4000 so it fails the MAE < 3500 test.

By adding layers to the model, like

model = tf.keras.Sequential([
    layers.Dense(64, activation='relu'),
    layers.Dense(128, activation='relu'),
    layers.Dense(256, activation='relu'),
    layers.Dense(1)
    ])

I get a MAE of about 2000 so it passes the test.

The certification project is named “Linear Regression Health Costs Calculator”. However, in the project instructions it says:

“In this challenge, you will predict healthcare costs using a regression algorithm.”

(so, it doesn’t specify it has to be linear regression, it only says regression).

I asked AI and it says that the simple model with only one layer is linear regression, but the second one, having multiple layers with ReLU activation functions, is a deep neural network regression model, but not a linear one.

My question is:
Considering all of the above, is it ok to submit for certification the second model, or it really has to be something like the first one (without multiple layers)? I tried tuning the simple one by changing optimizers, loss functions, learning rates etc. but I can’t get it under 4000 MAE.

Your code so far

model = tf.keras.Sequential([layers.Dense(units=1)])

vs.

model = tf.keras.Sequential([
    layers.Dense(64, activation='relu'),
    layers.Dense(128, activation='relu'),
    layers.Dense(256, activation='relu'),
    layers.Dense(1)
    ])

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36

Challenge Information:

Machine Learning with Python Projects - Linear Regression Health Costs Calculator

Yes, it can be done with a single layer neural network/linear regression, provided that you do some feature engineerings. My experience is the MAE with single layer NN can be lowered to 1600s or even 1300s after some tweaks of features.

Yep, I solved it on a single layer by performing feature engineering (adding interaction and polynomial features to the dataset). My mistake was that I was focused on tuning the model while the dataset could still be improved.

1 Like