Does glmnet provide any mechanisms to extract the regularization path from a final model? I'm using Elastic Nets (and L1) to build a binomial classifier and would like to be able to get the coefficients at each step along the path (until convergence).
The elasticnet
R package has this in the beta
variable of the model, but it looks like glmnet
only provides the final coefficients for each model. Any suggestions for how to go about pulling this out?
Best Answer
glmnet
provides a full coefficient path. Try the following example out for yourself:The number of lambdas tested is contingent on the random seed and properties in the data. To illustrate this, change the above example such that you are starting with
set.seed(111)
and you'll end up with 55 lambdas tested instead of 63. It's possible that lasso is converging extremely quickly for you and glmnet isn't even bothering to give you more than one lambda. I doubt that's the case, but it's probably possible.If you are specifying
lambda
in your call toglmnet
, then you won't get a coefficient path since the path is only meaningful over varying lambdas. If this doesn't answer your question, try to provide a minimal working example of your code.