【问题标题】:How to pass user specified indices into caret trainControl?如何将用户指定的索引传递到插入符 trainControl?
【发布时间】:2015-06-23 07:20:26
【问题描述】:

我正在处理一个需要大量预处理的数据集,为了防止过度拟合,我自己构建了交叉验证折叠。所以我有一个数据集,其中前 k 个记录属于折叠 1(我还有一个 fold_number 列来指定记录所属的折叠)第二个 k 记录属于折叠 2 等。我想使用 caret 包并使用交叉验证调整参数,但我不知道如何将每个折叠的 id 传递给 trainControl() 函数,而不仅仅是让 R 为我交叉验证。有人有什么想法吗?

【问题讨论】:

    标签: r cross-validation indices r-caret


    【解决方案1】:

    您正在寻找trainControlindexindexOut 参数。这在文档??trainControl中明确定义了

    ...
    index       a list with elements for each resampling iteration. 
                Each list element is the sample rows used for training 
                at that iteration.
    
    indexOut    a list (the same length as index) that dictates which sample 
                are held-out for each resample. If NULL, then the unique set 
                of samples not contained in index is used.
    ...
    

    这也在邮件列表here 中得到解决。

    【讨论】:

      猜你喜欢
      • 2015-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多