首页 > 解决方案 > xgb-wrapper 交叉验证 (xgb.cv) 的结果是什么?

问题描述

我无法理解 xgb.cv 的输出:1)它是一个 k 折还是最佳 k 折的结果?2) 在训练集和测试集上分割数据集的原则是什么——KFold 或 0.8/0.2?

当我运行代码时,我看到了计算过程。它在以最佳成绩提前停止回合后停止。

当然:#模型参数

num_parallel_tree = 1 
subsample = 1 
colsample_bytree = 0.4
objective = 'binary:logistic'
learning_rate = 0.05
eval_metric = 'auc'
max_depth = 10
min_child_weight = 4

n_estimators = 5000
seed = 7

#cross-validation parameters
nfold = 5
early_stopping_rounds = 5


bst_cv = xgb.cv(
    param, 
    dtrain,  
    num_boost_round=n_estimators, 
    nfold = nfold,
    early_stopping_rounds=early_stopping_rounds,
    verbose_eval=True
)

results:
[0] train-auc:0.910342+0.0015485    test-auc:0.850442+0.00619299
[1] train-auc:0.956268+0.00132653   test-auc:0.893746+0.00973467
...
[24]    train-auc:0.984302+0.000617268  test-auc:0.934326+0.00338043

然后 - 停止。

标签: pythoncross-validationxgboost

解决方案


推荐阅读