[Breaking] Update sklearn interface. (#4929)
* Remove nthread, seed, silent. Add tree_method, gpu_id, num_parallel_tree. Fix #4909. * Check data shape. Fix #4896. * Check element of eval_set is tuple. Fix #4875 * Add doc for random_state with hogwild. Fixes #4919
This commit is contained in:
@@ -175,6 +175,21 @@ def test_feature_importances_gain():
|
||||
np.testing.assert_almost_equal(xgb_model.feature_importances_, exp)
|
||||
|
||||
|
||||
def test_num_parallel_tree():
|
||||
from sklearn.datasets import load_boston
|
||||
reg = xgb.XGBRegressor(n_estimators=4, num_parallel_tree=4,
|
||||
tree_method='hist')
|
||||
boston = load_boston()
|
||||
bst = reg.fit(X=boston['data'], y=boston['target'])
|
||||
dump = bst.get_booster().get_dump(dump_format='json')
|
||||
assert len(dump) == 16
|
||||
|
||||
reg = xgb.XGBRFRegressor(n_estimators=4)
|
||||
bst = reg.fit(X=boston['data'], y=boston['target'])
|
||||
dump = bst.get_booster().get_dump(dump_format='json')
|
||||
assert len(dump) == 4
|
||||
|
||||
|
||||
def test_boston_housing_regression():
|
||||
from sklearn.metrics import mean_squared_error
|
||||
from sklearn.datasets import load_boston
|
||||
@@ -430,18 +445,18 @@ def test_split_value_histograms():
|
||||
|
||||
def test_sklearn_random_state():
|
||||
clf = xgb.XGBClassifier(random_state=402)
|
||||
assert clf.get_xgb_params()['seed'] == 402
|
||||
assert clf.get_xgb_params()['random_state'] == 402
|
||||
|
||||
clf = xgb.XGBClassifier(seed=401)
|
||||
assert clf.get_xgb_params()['seed'] == 401
|
||||
clf = xgb.XGBClassifier(random_state=401)
|
||||
assert clf.get_xgb_params()['random_state'] == 401
|
||||
|
||||
|
||||
def test_sklearn_n_jobs():
|
||||
clf = xgb.XGBClassifier(n_jobs=1)
|
||||
assert clf.get_xgb_params()['nthread'] == 1
|
||||
assert clf.get_xgb_params()['n_jobs'] == 1
|
||||
|
||||
clf = xgb.XGBClassifier(nthread=2)
|
||||
assert clf.get_xgb_params()['nthread'] == 2
|
||||
clf = xgb.XGBClassifier(n_jobs=2)
|
||||
assert clf.get_xgb_params()['n_jobs'] == 2
|
||||
|
||||
|
||||
def test_kwargs():
|
||||
@@ -482,7 +497,7 @@ def test_kwargs_error():
|
||||
def test_sklearn_clone():
|
||||
from sklearn.base import clone
|
||||
|
||||
clf = xgb.XGBClassifier(n_jobs=2, nthread=3)
|
||||
clf = xgb.XGBClassifier(n_jobs=2)
|
||||
clf.n_jobs = -1
|
||||
clone(clf)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user