Fix r early stop with custom objective. (#5923)

* Specify `ntreelimit`.
This commit is contained in:
Jiaming Yuan
2020-07-23 03:28:17 +08:00
committed by GitHub
parent 30363d9c35
commit bc1d3ee230
3 changed files with 12 additions and 4 deletions

View File

@@ -210,7 +210,7 @@ class TestModels(unittest.TestCase):
def evalerror(preds, dtrain):
labels = dtrain.get_label()
return 'error', float(sum(labels != (preds > 0.0))) / len(labels)
return 'error', float(sum(labels != (preds > 0.5))) / len(labels)
# test custom_objective in training
bst = xgb.train(param, dtrain, num_round, watchlist, logregobj, evalerror)