Created
June 18, 2020 04:26
-
-
Save necronet/d48188717f3e89601ba8bc8e4d6ca1bc to your computer and use it in GitHub Desktop.
Quick gist to show lambda selection difference between explicit and heuristic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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