Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick gist to show lambda selection difference between explicit and heuristic
library(glmnet)
x_var <- data.matrix(mtcars[, c("hp", "wt", "drat")])
y_var <- mtcars[, "mpg"]
fit_lambda_specified <- cv.glmnet(x_var, y_var, alpha = 0, lambda = 10^seq(5, -5, by = -.1))
fit_lambda_automatic <- cv.glmnet(x_var, y_var, alpha = 0)
plot(fit_lambda_specified, xvar="lambda")
plot(fit_lambda_automatic, xvar="lambda")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment