Handle the new device parameter in dask and demos. (#9386)
* Handle the new `device` parameter in dask and demos. - Check no ordinal is specified in the dask interface. - Update demos. - Update dask doc. - Update the condition for QDM.
This commit is contained in:
@@ -322,3 +322,15 @@ class TestQuantileDMatrix:
|
||||
X: np.ndarray = np.array(orig, dtype=dtype)
|
||||
with pytest.raises(ValueError):
|
||||
xgb.QuantileDMatrix(X)
|
||||
|
||||
def test_changed_max_bin(self) -> None:
|
||||
n_samples = 128
|
||||
n_features = 16
|
||||
csr, y = make_sparse_regression(n_samples, n_features, 0.5, False)
|
||||
Xy = xgb.QuantileDMatrix(csr, y, max_bin=9)
|
||||
booster = xgb.train({"max_bin": 9}, Xy, num_boost_round=2)
|
||||
|
||||
Xy = xgb.QuantileDMatrix(csr, y, max_bin=11)
|
||||
|
||||
with pytest.raises(ValueError, match="consistent"):
|
||||
xgb.train({}, Xy, num_boost_round=2, xgb_model=booster)
|
||||
|
||||
@@ -27,7 +27,7 @@ def train_result(param, dmat, num_rounds):
|
||||
param,
|
||||
dmat,
|
||||
num_rounds,
|
||||
[(dmat, "train")],
|
||||
evals=[(dmat, "train")],
|
||||
verbose_eval=False,
|
||||
evals_result=result,
|
||||
)
|
||||
@@ -169,13 +169,21 @@ class TestTreeMethod:
|
||||
hist_res = {}
|
||||
exact_res = {}
|
||||
|
||||
xgb.train(ag_param, ag_dtrain, 10,
|
||||
[(ag_dtrain, 'train'), (ag_dtest, 'test')],
|
||||
evals_result=hist_res)
|
||||
xgb.train(
|
||||
ag_param,
|
||||
ag_dtrain,
|
||||
10,
|
||||
evals=[(ag_dtrain, "train"), (ag_dtest, "test")],
|
||||
evals_result=hist_res
|
||||
)
|
||||
ag_param["tree_method"] = "exact"
|
||||
xgb.train(ag_param, ag_dtrain, 10,
|
||||
[(ag_dtrain, 'train'), (ag_dtest, 'test')],
|
||||
evals_result=exact_res)
|
||||
xgb.train(
|
||||
ag_param,
|
||||
ag_dtrain,
|
||||
10,
|
||||
evals=[(ag_dtrain, "train"), (ag_dtest, "test")],
|
||||
evals_result=exact_res
|
||||
)
|
||||
assert hist_res['train']['auc'] == exact_res['train']['auc']
|
||||
assert hist_res['test']['auc'] == exact_res['test']['auc']
|
||||
|
||||
|
||||
@@ -1349,10 +1349,11 @@ def test_multilabel_classification() -> None:
|
||||
np.testing.assert_allclose(clf.predict(X), predt)
|
||||
|
||||
|
||||
def test_data_initialization():
|
||||
def test_data_initialization() -> None:
|
||||
from sklearn.datasets import load_digits
|
||||
|
||||
X, y = load_digits(return_X_y=True)
|
||||
validate_data_initialization(xgb.DMatrix, xgb.XGBClassifier, X, y)
|
||||
validate_data_initialization(xgb.QuantileDMatrix, xgb.XGBClassifier, X, y)
|
||||
|
||||
|
||||
@parametrize_with_checks([xgb.XGBRegressor()])
|
||||
|
||||
Reference in New Issue
Block a user