[Python] Accept numpy generators as random_state (#9743)

* accept numpy generators for random_state

* make linter happy

* fix tests
This commit is contained in:
david-cortes
2023-11-02 00:20:44 +01:00
committed by GitHub
parent 4da4e092b5
commit be20df8c23
2 changed files with 12 additions and 2 deletions

View File

@@ -702,6 +702,10 @@ def test_sklearn_random_state():
clf = xgb.XGBClassifier(random_state=random_state)
assert isinstance(clf.get_xgb_params()['random_state'], int)
random_state = np.random.default_rng(seed=404)
clf = xgb.XGBClassifier(random_state=random_state)
assert isinstance(clf.get_xgb_params()['random_state'], int)
def test_sklearn_n_jobs():
clf = xgb.XGBClassifier(n_jobs=1)