Reputation: 1841
How can I set xgboost.train to opitimize for a specific evaluation metric similar to how I can set xgboost.fit(eval_metric = 'auc')?
Upvotes: 3
Views: 32391
Reputation: 9148
You have to set it in the parameters.
E.g.:
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')],
)
Upvotes: 1