如何为xgboost.train设置评估指标?

2024-04-19 23:12:43 发布

您现在位置:Python中文网/ 问答频道 /正文

如何设置xgboost.train以优化特定评估指标,类似于如何设置xgboost.fit(eval_metric='auc')


Tags: evaltrain指标metricfitxgboostauc
2条回答

您必须在参数中设置它

例如:

params = {
 'objective': 'multi:softprob',
 'tree_method': 'gpu_hist',
 'num_class': 27,
 'seed': 0,
 'max_depth': 2,
 'colsample_bytree': 0.36524046160303747,
 'colsample_bylevel': 0.7008644188368828,
 'grow_policy': 'lossguide',
 'lambda': 1-08,
 'alpha': 0.1,
 'subsample': 0.9,
 'eta': 0.01,
 'eval_metric': 'merror'}

xgb.train(params, dX_train, 
          num_boost_round=100, 
          verbose_eval=10, 
          early_stopping_rounds=10, 
          evals=[(dX_train, 'train') , (dX_valid, 'valid')],
          )

见文件here。您可以在eval_metric下找到度量xgboost支持

如果要使用自定义目标函数或度量,请参见here

相关问题 更多 >