0
$\begingroup$

I have trained a ElasticNet model on a A dataset and also I get the two hyperparameters of the trained ElasticNet model Lambda (ratio of Lasso and Ridge) and Alpha (penalty). I want to see the generalization of the model on the B dataset. If I don't use sklearn's predict method directly, can I directly specify the previous Lambda and Alpha to build a new model and see the performance in the new database? In other words, can Lambda and Alpha determine a unique ElasticNet model?

Any help is greatly appreciated!

Ito

$\endgroup$

1 Answer 1

0
$\begingroup$

Both hyperparameters ($\alpha$ and $\lambda$) are specific to a dataset, they are chosen such as to optimize some criterion for the specified data. Training the model on a different dataset will probably return different optimal values of the two, so these hyperparameters are not really transferable, not unless these two datasets contain more or less similar data. But if you were to do this then it is as easy as specifying a value for the two hyperparameter and a model will be trained with exactly these hyperparameter values, then you can check how well the model performs on a different dataset with given hyperparameters, although what will you compare this to?

$\endgroup$
5
  • $\begingroup$ Thanks, your answer is very enlightening. It is quite true that both hyperparameters (α and λ) are specific to a dataset. Then, the features in the model and their corresponding coefficients are transferable. Is this right? $\endgroup$
    – Kengo Ito
    Commented Jan 10, 2023 at 13:44
  • $\begingroup$ @KengoIto What do you mean by the model and their corresponding coefficients are transferable? $\endgroup$ Commented Jan 10, 2023 at 14:15
  • $\begingroup$ Thanks! For an ElasticNet model, if I have 200 features at the beginning, there are 150 features left after training. I want to apply this model to new data, I just need to substitute the values of 150 features of the new data into the original model (y_new = feature1_new x coefficient1 + feature2_new x coefficient2 + ... +feature150_new x coefficient150), get y (response), and then calculate the performance of the model on new data. $\endgroup$
    – Kengo Ito
    Commented Jan 11, 2023 at 2:40
  • $\begingroup$ In other words, for an ElasticNet model (a linear model with a penalty term), y_new = feature1_new x coefficient1 + feature2_new x coefficient2 + ... +feature150_new x coefficient150 can fully represent the model. It's a bit long-winded, please forgive me. $\endgroup$
    – Kengo Ito
    Commented Jan 11, 2023 at 2:40
  • $\begingroup$ @KengoIto I'm not sure I understand. LASSO and RIDGE shrink coefficients but they still keep all the coefficients in the model, they don't drop them, even if they are zero. So if you have two datasets A and B with the same variables, you could train the model on dataset A and then use the model to make predictions on dataset B, no modification is necessary. $\endgroup$ Commented Jan 12, 2023 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.