isds2020 icon indicating copy to clipboard operation
isds2020 copied to clipboard

Problem with 11.2.2 : The calculated RMSE's are all the same for every value of lambda

Open Johan-Christensen opened this issue 5 years ago • 2 comments
trafficstars

Hi, I am trying to complete problem 11.2.2. However, when I run the code below, I get the same RMSE for every value of lambda.

image

(Note: X_train_ps has polynomialfeatures added and is scaled with zero mean and std, same with X_test_ps)

This is my mse function: image

My compute_error function: image

Johan-Christensen avatar Aug 18 '20 18:08 Johan-Christensen

hi @Johan-Christensen , you should define a new Lasso model with the given lambda value in each iteration. From your code it does not look like you utilize the lambdas for anything in your loop. Right now you are using your own coded estimator. Use the Lasso from sklearn.linear_model :)

Also, you are defining the list lambdas to contain 1000 values between 10^(-4) to 10^(4). Considering the index of your dataframe the difference in the value of two consecutive lambdas is miniscule. Thus we would not expect a big different in the RMSEs between two consecutive entries using the lamba values in your dataframe. Try to limit the length of the list to only 20 values (for your 💻's sake )

jsr-p avatar Aug 19 '20 08:08 jsr-p

Thanks!

Johan-Christensen avatar Aug 19 '20 08:08 Johan-Christensen