Fix gpu_id with custom objective. (#7015)

This commit is contained in:
Jiaming Yuan
2021-06-09 14:51:17 +08:00
committed by GitHub
parent bd2ca543c4
commit 72f9daf9b6
3 changed files with 19 additions and 6 deletions

View File

@@ -138,8 +138,13 @@ class TestModels:
# behaviour is considered sub-optimal, feel free to change.
assert booster.num_boosted_rounds() == 4
def test_custom_objective(self):
param = {'max_depth': 2, 'eta': 1, 'objective': 'reg:logistic'}
def run_custom_objective(self, tree_method=None):
param = {
'max_depth': 2,
'eta': 1,
'objective': 'reg:logistic',
"tree_method": tree_method
}
watchlist = [(dtest, 'eval'), (dtrain, 'train')]
num_round = 10
@@ -181,6 +186,9 @@ class TestModels:
if int(preds2[i] > 0.5) != labels[i]) / float(len(preds2))
assert err == err2
def test_custom_objective(self):
self.run_custom_objective()
def test_multi_eval_metric(self):
watchlist = [(dtest, 'eval'), (dtrain, 'train')]
param = {'max_depth': 2, 'eta': 0.2, 'verbosity': 1,