我执行一个惩罚的逻辑回归,我用插入符号(glmnet)训练模型 .
model_fit <- train(Data[,-1], Data[,1],
method = "glmnet",
family="binomial",
metric = "ROC",
maximize="TRUE",
trControl = ctrl,
preProc = c("center", "scale"),
tuneGrid=expand.grid(.alpha=0.5,.lambda=lambdaSeq)
)
根据插入符号文档,函数 train
"[...] calculates a resampling based performance measure"和"Across each data set, the performance of held-out samples is calculated and the mean and standard deviation is summarized for each combination."
results
是"A data frame"(含)"the training error rate and values of the tuning parameters."
model_fit$results$ROC
是一个向量(大小等于我的调整参数 lambda
的大小),是重新采样的性能指标的平均值吗? (并且,对于 lambda
的每个值,在整个样本上重新估计模型后,不是对整个样本计算的性能指标?)
1 回答
它是;确切地说,长度将等于
tuneGrid
的行数,在这里它恰好与lambdaSeq
的长度一致(因为唯一的其他参数,alpha
,保持不变) .这是一个快速的例子,改编自caret docs(它与
gbm
和Accuracy
度量,但想法是一样的):这里,
gbmGrid
有3行,即它只包含三(3)个不同的n.trees
值,其他参数保持不变;因此,相应的gbmFit1$results$Accuracy
将是一个长度为3的向量:返回的3
Accuracy
值中的每一个都是我们用作重采样技术的5倍交叉验证的验证折叠中的度量的结果;更确切地说,它是在这5个折叠中计算的验证精度的平均值(并且您可以看到有一个AccuracySD
列,也包含其标准偏差) .正确,不是那样的 .