r - R Xgboost 验证错误作为停止指标
问题描述
我在 xgboost 二进制分类模型上使用训练和验证数据集。
params5 <- list(booster = "gbtree", objective = "binary:logistic",
eta=0.0001, gamma=0.5, max_depth=15, min_child_weight=1, subsample=0.6,
colsample_bytree=0.4,seed =2222)
xgb_MOD5 <- xgb.train (params = params5, data = dtrain, nrounds = 4000,
watchlist = list(validation = dvalid,train = dtrain),
print_every_n =30,early_stopping_rounds = 100
maximize = F ,serialize = TRUE)
它会自动选择火车误差作为停止指标。这导致模型在过度拟合时继续训练。
Multiple eval metrics are present. Will use train_error for early stopping.
Will train until train_error hasn't improved in 100 rounds.
如何将验证错误分配为停止指标?
解决方案
我不使用 xgboost 的 R 绑定,并且 R-package 文档没有具体说明它。但是,python-API 文档(请参阅early_stopping_rounds
参数文档)对此问题进行了相关说明:
中至少需要一项
evals
。如果有多个,将使用最后一个。
这里evals
是评估指标的样本列表,即类似于您的watchlist
论点。所以我猜,您可能只需要交换作为该参数提供的列表中的项目顺序
推荐阅读
- kubernetes - 如何解析 kubectl describe 输出并获取所需的字段值
- spring - 从动态库加载 JWT 签名密钥
- azure - 邮递员:无法使用 Azure MongoDB API 创建文档
- ios - 如何将日志发送到 iOS 应用程序中的 Lambda 函数?
- excel - 如何使用 VBA 或 Powershell 将具有 NTLM 身份验证的 Sharepoint 服务器中的列表导出到 Excel
- powershell - 远程启动服务
- apostrophe-cms - apostrophecms apostrophe-search 抛出 apostrophe-attachment 的模板警告
- java - HashSet 初始容量参数是指我希望存储的桶数或元素数?
- leaflet - 传单地图未使用 rmarkdown 在 html 文档中呈现
- mapbox - react-map-gl 没有使用 osm 瓦片的 API 密钥