Restore functionality of max_depth=0 in hist (#7551)

* Restore functionality of max_depth=0 in hist

* Add test case
This commit is contained in:
Philip Hyunsu Cho
2022-01-10 09:37:44 -08:00
committed by GitHub
parent 2db808021d
commit 20c0d60ac7
2 changed files with 16 additions and 1 deletions

View File

@@ -60,3 +60,18 @@ class TestTreeRegularization:
# sum_hess = 1.0
# 0.7 = 0.5 - (sum_grad - alpha * sgn(sum_grad)) / (sum_hess + lambda)
assert_approx_equal(preds[0], 0.7)
def test_unlimited_depth(self):
x = np.array([[0], [1], [2], [3]])
y = np.array([0, 1, 2, 3])
model = xgb.XGBRegressor(
n_estimators=1,
eta=1,
tree_method="hist",
grow_policy="lossguide",
reg_lambda=0,
max_leaves=128,
max_depth=0,
).fit(x, y)
assert np.array_equal(model.predict(x), y)