是否可以从R Caret包中获得所有交叉验证集的系数?
set.seed(1)
mu <- rep(0, 4)
Sigma <- matrix(.7, nrow=4, ncol=4)
diag(Sigma) <- 1
rawvars <- mvrnorm(n=1000, mu=mu, Sigma=Sigma)
d <- as.ordered(
as.numeric(rawvars[,1]>0.5) )
d[1:200] <- 1
df <- data.frame(rawvars, d)
ind <- sample(1:nrow(df), 500)
train <- df[ind,]
test <- df[-ind,]
trControl <- trainControl(method = "repeatedcv",
repeats = 1,
classProb = T,
summaryFunction= twoClassSummary)
fit.caret <- train(d~., data=train,
method="glm",
family = binomial(link="probit"), trControl =trControl)
> fit.caret$resample
ROC Sens Spec Resample
1 0.8383838 0.8148148 0.7272727 Fold01.Rep1
2 0.8881988 0.8571429 0.7391304 Fold02.Rep1
3 0.8937198 0.8518519 0.7826087 Fold03.Rep1
4 0.8792271 0.7407407 0.8260870 Fold04.Rep1
5 0.8771044 0.8888889 0.7727273 Fold05.Rep1
6 0.8703704 0.6666667 0.7727273 Fold06.Rep1
7 0.9145963 0.8928571 0.8260870 Fold07.Rep1
8 0.8649068 0.6785714 0.8260870 Fold08.Rep1
9 0.8084416 0.8928571 0.6818182 Fold09.Rep1
10 0.7938312 0.7857143 0.6363636 Fold10.Rep1
我每次重复都有ROC,但我也需要每次运行的系数