Init estimation for regression. (#8272)
This commit is contained in:
@@ -224,5 +224,6 @@ Arrow specification.'''
|
||||
dtrain = dmatrix_from_cupy(
|
||||
np.float32, xgb.DeviceQuantileDMatrix, np.nan)
|
||||
with pytest.raises(xgb.core.XGBoostError):
|
||||
xgb.train({'tree_method': 'gpu_hist', 'gpu_id': 1},
|
||||
dtrain, num_boost_round=10)
|
||||
xgb.train(
|
||||
{'tree_method': 'gpu_hist', 'gpu_id': 1}, dtrain, num_boost_round=10
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@ import numpy as np
|
||||
import pytest
|
||||
from hypothesis import assume, given, note, settings, strategies
|
||||
from xgboost.testing.params import cat_parameter_strategy, hist_parameter_strategy
|
||||
from xgboost.testing.updater import check_init_estimation
|
||||
|
||||
import xgboost as xgb
|
||||
from xgboost import testing as tm
|
||||
@@ -172,24 +173,25 @@ class TestGPUUpdaters:
|
||||
kCols = 100
|
||||
|
||||
X = np.empty((kRows, kCols))
|
||||
y = np.empty((kRows))
|
||||
y = np.empty((kRows,))
|
||||
|
||||
dtrain = xgb.DMatrix(X, y)
|
||||
|
||||
bst = xgb.train({'verbosity': 2,
|
||||
'tree_method': 'gpu_hist',
|
||||
'gpu_id': 0},
|
||||
dtrain,
|
||||
verbose_eval=True,
|
||||
num_boost_round=6,
|
||||
evals=[(dtrain, 'Train')])
|
||||
bst = xgb.train(
|
||||
{"verbosity": 2, "tree_method": "gpu_hist", "gpu_id": 0},
|
||||
dtrain,
|
||||
verbose_eval=True,
|
||||
num_boost_round=6,
|
||||
evals=[(dtrain, 'Train')]
|
||||
)
|
||||
|
||||
kRows = 100
|
||||
X = np.random.randn(kRows, kCols)
|
||||
|
||||
dtest = xgb.DMatrix(X)
|
||||
predictions = bst.predict(dtest)
|
||||
np.testing.assert_allclose(predictions, 0.5, 1e-6)
|
||||
# non-distributed, 0.0 is returned due to base_score estimation with 0 gradient.
|
||||
np.testing.assert_allclose(predictions, 0.0, 1e-6)
|
||||
|
||||
@pytest.mark.mgpu
|
||||
@given(tm.dataset_strategy, strategies.integers(0, 10))
|
||||
@@ -204,3 +206,6 @@ class TestGPUUpdaters:
|
||||
@pytest.mark.parametrize("weighted", [True, False])
|
||||
def test_adaptive(self, weighted) -> None:
|
||||
self.cputest.run_adaptive("gpu_hist", weighted)
|
||||
|
||||
def test_init_estimation(self) -> None:
|
||||
check_init_estimation("gpu_hist")
|
||||
|
||||
Reference in New Issue
Block a user