From ac7fc1306b70e8dae7f57438650918dcc79ba184 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Thu, 16 Aug 2018 19:05:40 -0700 Subject: [PATCH] Fix #3598: document that custom objective can't contain colon (:) (#3601) --- demo/guide-python/custom_objective.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/guide-python/custom_objective.py b/demo/guide-python/custom_objective.py index cf35db0b0..349b3081d 100755 --- a/demo/guide-python/custom_objective.py +++ b/demo/guide-python/custom_objective.py @@ -33,10 +33,10 @@ def logregobj(preds, dtrain): # Take this in mind when you use the customization, and maybe you need write customized evaluation function def evalerror(preds, dtrain): labels = dtrain.get_label() - # return a pair metric_name, result + # return a pair metric_name, result. The metric name must not contain a colon (:) # since preds are margin(before logistic transformation, cutoff at 0) return 'error', float(sum(labels != (preds > 0.0))) / len(labels) # training with customized objective, we can also do step by step training # simply look at xgboost.py's implementation of train -bst = xgb.train(param, dtrain, num_round, watchlist, logregobj, evalerror) +bst = xgb.train(param, dtrain, num_round, watchlist, obj=logregobj, feval=evalerror)