gpt4 book ai didi

r - 如何在 XGBoost 中使用自定义交叉验证折叠

转载 作者:行者123 更新时间:2023-12-04 19:52:23 27 4
gpt4 key购买 nike

我正在为 XGBoost 使用 R 包装器。在函数 xgb.cv 中,有一个 folds带描述的参数

list provides a possibility of using a list of pre-defined CV folds (each element must be a vector of fold's indices). If folds are supplied, the nfold and stratified parameters would be ignored.



那么,我是否只指定用于训练模型的索引并假设其余的将用于测试?例如,如果我的训练数据类似于
    Feature1 Feature2 Target
1: 2 10 10
2: 7 1 9
3: 8 2 3
4: 8 10 7
5: 8 2 9
6: 3 7 3

我想使用 (train, test) 指数作为 ((1,2,3), (4,5,6)) 和 ((4,5,6), (1,2,3)) 进行交叉验证我设置了 folds=list(c(1,2,3), c(4,5,6)) ?

最佳答案

通过一些试验和错误,我发现 xgboost使用传递的索引作为测试折叠的索引。通过注意到 xgboost 的当前开发版本确认了这一点在 documentation 中明确说明了它.

关于r - 如何在 XGBoost 中使用自定义交叉验证折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38287223/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com