Python XG加速CV和提前停止
我正在尝试使用XGBoost.cv并根据mlogloss提前停止:Python XG加速CV和提前停止,python,scikit-learn,cross-validation,xgboost,Python,Scikit Learn,Cross Validation,Xgboost,我正在尝试使用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,
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
测试mlogloss随着每个历元而下降,因此,我希望运行不会终止(因为精度必须提高)。我哪里做错了
谢谢 我没有设置num_rounds参数,该参数默认为10。简单