SelfExplainML / PiML-Toolbox

PiML (Python Interpretable Machine Learning) toolbox for model development & diagnostics
https://selfexplainml.github.io/PiML-Toolbox
Apache License 2.0
912 stars 109 forks source link

Replicating sklearn elastic net results in PiML #26

Closed xloffree closed 1 year ago

xloffree commented 1 year ago

Hi,

I trained an elastic net model using sklearn in python (from sklearn.linear_model import ElasticNet). I used the following parameters: ElasticNet(alpha = 0.434, l1_ratio = 0.5) . What can I enter into the L1 and L2 input in the GLM model in PiML to replicate these results (assuming I am using the same data with the same random seed)?

Thanks

CnBDM-Su commented 1 year ago

@xloffree Hi, L1 and L2 should both be 0.217. The example is attached. image

xloffree commented 1 year ago

I tried this and when I run model_explain it says that all coefficients are equal to zero. What is going on here? The elastic net worked fine with sklearn and with R. Is there something wrong?

Thank you

CnBDM-Su commented 1 year ago

@xloffree Can you show the example to me? In my test, our GLM result is always same to the sklearn elasticnet.

xloffree commented 12 months ago
Screenshot 2023-07-29 at 7 04 05 PM Screenshot 2023-07-29 at 7 04 17 PM Screenshot 2023-07-29 at 7 04 28 PM Screenshot 2023-07-29 at 7 04 51 PM Screenshot 2023-07-29 at 7 06 26 PM

When using GLMRegressor, I get very different results than from when I use the method shown in the README, which gives a very poor R2 and says all coefficients are 0. I am certain that this is wrong because we have run elastic net on this data in R and python and have gotten similar results that show a much better R2. The results from the glmRegressor look more reasonable. I am trying to use piml to compare many models at once on the same train/test split (the elastic net models with specific parameters included). We would like to use the results from PiML in an upcoming paper, but this problem with PiML's elastic net is preventing us from being able to do so. Please let me know if there is a solution to this.

Thank you