【发布时间】:2018-01-26 21:54:20
【问题描述】:
我想知道为什么来自“Fold1”的预测实际上是来自我预定义折叠中的第二个折叠的预测。我附上一个例子来说明我的意思。
# load the library
library(caret)
# load the cars dataset
data(cars)
# define folds
cv_folds <- createFolds(cars$Price, k = 5, list = TRUE, returnTrain = TRUE)
# define training control
train_control <- trainControl(method="cv", index = cv_folds, savePredictions = 'final')
# fix the parameters of the algorithm
# train the model
model <- caret::train(Price~., data=cars, trControl=train_control, method="gbm", verbose = F)
model$pred$rowIndex[model$pred$Resample == 'Fold1'] %in% cv_folds[[2]]
【问题讨论】:
-
你能附上一些输出数据吗?也许平均交叉验证分数作为第一个索引返回?
标签: r cross-validation r-caret