【发布时间】:2020-09-29 23:26:24
【问题描述】:
我正在训练 Elastic Net 模型,发现 lambda.1se 远高于 lambda.min,通常是在选择零特征的情况下测试的最大 lambda。我猜这是因为我的标准偏差真的很大。
有没有办法让cv.glmnet 在lambda.1se 和lambda.min 之间选择一个值?
x = matrix(rnorm(100 * 20), 100, 20) # not the actual data
y = gl(2, 50)
fit <- cv.glmnet(
x = x, y = y,
family = "binomial",
nfolds = nrow(x), grouped = F,
standardize = T,
alpha = 0.2
)
【问题讨论】:
-
您可以在
fit$lambda中使用一组lambda值。如果lambda.1se太稀疏,您可能需要根据fit$nzero选择lambda。