-->

插入符。 数据分割和trainControl的关系(CARET. Relationship be

2019-08-17 01:39发布

我已经仔细阅读CARET在文档: http://caret.r-forge.r-project.org/training.html的护身符,一切都是很清楚(网站上的例子有很大的帮助!),但我仍然是一个困惑于两个参数之间的关系trainControl

method 
index

和之间的相互作用trainControl和插入符号数据分割功能(例如createDataPartitioncreateResamplecreateFoldscreateMultiFolds

为了更好的框架,我的问题,让我用从文档下面的例子:

data(BloodBrain)
set.seed(1)
tmp <- createDataPartition(logBBB,p = .8, times = 100)
trControl = trainControl(method = "LGOCV", index = tmp)
ctreeFit <- train(bbbDescr, logBBB, "ctree",trControl=trControl)

我的问题是:

  1. 如果我使用createDataPartition在上面的例子(我认为不分层引导),因为和我通过结果作为indextrainControl做我需要使用LGOCV在我的电话的方法trainControl ? 如果我用另外一个(如cv )将有什么不同? 在我的头上,一旦你修复index ,实质上是选择交叉验证的类型,所以我不知道什么样的作用method ,如果你使用起着index

  2. 是什么区别createDataPartitioncreateResample ? 难道createDataPartition并分层引导,而createResample不?

3)如何可以做分层的k倍(例如,使用插入符号10倍)交叉验证? 将下面做呢?

tmp <- createFolds(logBBB, k=10, list=TRUE,  times = 100)
trControl = trainControl(method = "cv", index = tmp)
ctreeFit <- train(bbbDescr, logBBB, "ctree",trControl=trControl)

Answer 1:

如果你不知道你是否使用索引什么样的角色扮演的方法,为什么不适用所有的方法和结果进行比较。 这是comparaison的盲法,但它可以给你一些直觉。

  methods <- c('boot', 'boot632', 'cv', 
               'repeatedcv', 'LOOCV', 'LGOCV')

我创建我的索引:

  n <- 100
  tmp <- createDataPartition(logBBB,p = .8, times = n)

我申请trainControl对我的方法的列表,我删除从结果索引,因为它是常见的到我的所有方法。

ll <- lapply(methods,function(x)
         trControl = trainControl(method = x, index = tmp))
ll <- sapply(ll,'[<-','index', NULL)

因此,我LL是:

                 [,1]      [,2]      [,3]      [,4]         [,5]      [,6]     
method            "boot"    "boot632" "cv"      "repeatedcv" "LOOCV"   "LGOCV"  
number            25        25        10        10           25        25       
repeats           25        25        1         1            25        25       
verboseIter       FALSE     FALSE     FALSE     FALSE        FALSE     FALSE    
returnData        TRUE      TRUE      TRUE      TRUE         TRUE      TRUE     
returnResamp      "final"   "final"   "final"   "final"      "final"   "final"  
savePredictions   FALSE     FALSE     FALSE     FALSE        FALSE     FALSE    
p                 0.75      0.75      0.75      0.75         0.75      0.75     
classProbs        FALSE     FALSE     FALSE     FALSE        FALSE     FALSE    
summaryFunction   ?         ?         ?         ?            ?         ?        
selectionFunction "best"    "best"    "best"    "best"       "best"    "best"   
preProcOptions    List,3    List,3    List,3    List,3       List,3    List,3   
custom            NULL      NULL      NULL      NULL         NULL      NULL     
timingSamps       0         0         0         0            0         0        
predictionBounds  Logical,2 Logical,2 Logical,2 Logical,2    Logical,2 Logical,2


文章来源: CARET. Relationship between data splitting and trainControl