【问题标题】:XGBoost CV and early stoppingXGBoost CV 和提前停止
【发布时间】:2016-10-20 00:26:05
【问题描述】:

我正在尝试使用 XGBoost.cv 提前停止,基于 mlogloss:

params = {'booster': 'gbtree', 'objective': 'multi:softprob',
          'num_class': len(le.classes_), 'eta': 0.1,
          'max_depth': 10, 'subsample': 1.0,
          'scale_pos_weight': 1, 'min_child_weight': 5,
          'colsample_bytree': 0.2, 'gamma': 0, 'reg_alpha': 0,
          'reg_lambda': 1, 'eval_metric': 'mlogloss'}

res = xgb.cv(params, dm_train, nfold=5,
        seed=42, early_stopping_rounds=10, verbose_eval=True,
        metrics={'mlogloss'}, show_stdv=False)

print(res)

我对提前停止的理解是,如果我的评估指标在 n 轮(在本例中为 10 轮)没有改善,运行将终止。当我运行这段代码时,它会在 10 轮后终止,打印输出:

test-mlogloss-mean            
0:             6.107054               
1:             5.403606                    
2:             4.910938                   
3:             4.546221                    
4:             4.274113                  
5:             4.056968                  
6:             3.876368               
7:             3.728714                       
8:             3.599812                  
9:             3.485113                  

Test-mlogloss 在每个时期都在下降,因此,我预计运行不会终止(因为准确性必须提高)。我哪里错了?

谢谢。

【问题讨论】:

    标签: python scikit-learn cross-validation xgboost


    【解决方案1】:

    我没有设置 num_rounds 参数,默认为 10。简单。

    【讨论】:

    • 补充一下,参数现在叫“num_boost_round”
    猜你喜欢
    • 2017-09-18
    • 2020-05-19
    • 2017-08-17
    • 2017-10-02
    • 2018-09-13
    • 1970-01-01
    • 2016-03-29
    • 2021-03-09
    • 2017-03-22
    相关资源
    最近更新 更多