python-glmnet icon indicating copy to clipboard operation
python-glmnet copied to clipboard

What can be the reason for different results compared to R glmnet?

Open slavakx opened this issue 3 years ago • 0 comments

Hi,

I have the following pipeline. First I apply ridge regression using 10-cv to find the best lambda. I get same lambda max and lambda best as in R cv.glmnet.

Next, I refit the model using the best lambda from the first step, without intercept and compare it to the results of R glmnet. The coefficients and predictions are different. Why is that?

Comparison of coefficients: R (Intercept) 0
f1 -0.004059542 f2 0.377331808 f3 1.006589044 f4 0.876858914 f5 0.140710854 f6 730268.470575249 f7 244447.850561236 f8 537663.923355049 f9 176279.892636801 f10 662.748853227 f11 739399.127039033

python: Intercept 0 f1 -0.16957 f2 0.33352 f3 0.80749 f4 0.71330 f5 0.11385 f6 801091.27661 f7 293769.02256 f8 557147.70998 f9 251954.31707 f10 797640.12411 f11 1086129.27954

Thanks

slavakx avatar Jan 05 '22 10:01 slavakx