SGD Regressor having a very large loss for multiple features - Any Idea why?

Hello all,

So I was playing around with the code and noticed something odd (the title says it all). For more context, I would attach the code and the results.

LinearRegression - Multiple Features

inputs, targets = non_smoker_df[['age', 'bmi', 'children']], non_smoker_df['charges']

model = LinearRegression().fit(inputs, targets)

predictions = model.predict(inputs)

loss = rmse(targets, predictions)
print('Loss:', loss)

Loss: 4608.470405038245

SGDRegressor - Multiple Features

inputs, targets = non_smoker_df[['age', 'bmi', 'children']], non_smoker_df['charges']

model = SGDRegressor().fit(inputs, targets)

predictions = model.predict(inputs)

loss = rmse(targets, predictions)
print('Loss:', loss)

Loss: 1710955916.5947938

SGRRegressor - Single Feature

inputs, targets = non_smoker_df[['age']], non_smoker_df['charges']

model = SGDRegressor().fit(inputs, targets)

predictions = model.predict(inputs)

loss = rmse(targets, predictions)
print('Loss:', loss)

Loss: 5122.728586775853

Thank you in anticipation of your responses.

Increase the value of max_iter or learning_rate for SGDRegressor

See sklearn.linear_model.SGDRegressor — scikit-learn 0.24.2 documentation

Since Stochastic Gradient Descent is an iterative process, it may simply be the case that you need to run more iterations of the optimization process or use a higher learning rate.

Watch this video to understand SGD: Stochastic Gradient Descent, Clearly Explained!!! - YouTube

This post was flagged by the community and is temporarily hidden.