I want to verify the code to specify a ridge model, a lasso model, and an elastic net model, using parsnip and glmnet and the penalty and mixture arguments.
mixture : The proportion of L1 regularization in the model. and
mixture : A number between zero and one (inclusive) that represents the proportion of regularization that is used for the L2 penalty (i.e. weight decay, or ridge regression) versus L1 (the lasso) ( glmnet and spark only).
So I am not sure if the mixture represents the proportion of L1 or L2.
Is this the correct specification for a ridge model?
linear_reg(penalty = .10, mixture = 0) %>% # mixture = 0 meaning no L1 penalty
set_mode("regression") %>%
set_engine("glmnet") %>%
fit(y ~ ., data = dta)
Is this the correct specification for a lasso model?
linear_reg(penalty = .10, mixture = 1) %>% # mixture = 1 meaning no L2 penalty
set_mode("regression") %>%
set_engine("glmnet") %>%
fit(y ~ ., data = dta)
Is this the correct specification for an elastic net model?
linear_reg(penalty = .10, mixture = .6) %>% # this is a mixture of both L1 and L2. Is it 60% L1 or 60% L2?
set_mode("regression") %>%
set_engine("glmnet") %>%
fit(y ~ ., data = dta)
Assuming mixture works the same as alpha in glmnet::glmnet, 0 is L2 (ridge) only and 1 is L1 (lasso) only and anything in between is a proportional mixture of both. This would be consistent with the first description of mixture. Hopefully Max will drop by and provide a definitive answer. The documentation could probably be clarified both to make the two mixture descriptions consistent and also to explicitly state which is which, e.g., 0=L2 only and 1=L1 only.