Don't set_params at the end of set_state. (#4947)

* Don't set_params at the end of set_state.

* Also fix another issue found in dask prediction.

* Add note about prediction.

Don't support other prediction modes at the moment.
This commit is contained in:
Jiaming Yuan
2019-10-15 10:08:26 -04:00
committed by GitHub
parent 2ebdec8aa6
commit 7e72a12871
6 changed files with 70 additions and 8 deletions

View File

@@ -43,14 +43,17 @@ def test_from_dask_dataframe(client):
prediction = xgb.dask.predict(client, model=booster, data=dtrain)
assert prediction.ndim == 1
assert isinstance(prediction, da.Array)
assert prediction.shape[0] == kRows and prediction.shape[1] == kCols
assert prediction.shape[0] == kRows
with pytest.raises(ValueError):
# evals_result is not supported in dask interface.
xgb.dask.train(
client, {}, dtrain, num_boost_round=2, evals_result={})
prediction = prediction.compute() # force prediction to be computed
def test_from_dask_array(client):
X, y = generate_array()
@@ -59,10 +62,12 @@ def test_from_dask_array(client):
result = xgb.dask.train(client, {}, dtrain)
prediction = xgb.dask.predict(client, result, dtrain)
assert prediction.shape[0] == kRows and prediction.shape[1] == kCols
assert prediction.shape[0] == kRows
assert isinstance(prediction, da.Array)
prediction = prediction.compute() # force prediction to be computed
def test_regressor(client):
X, y = generate_array()
@@ -72,7 +77,8 @@ def test_regressor(client):
regressor.fit(X, y, eval_set=[(X, y)])
prediction = regressor.predict(X)
assert prediction.shape[0] == kRows and prediction.shape[1] == kCols
assert prediction.ndim == 1
assert prediction.shape[0] == kRows
history = regressor.evals_result()
@@ -91,7 +97,8 @@ def test_classifier(client):
classifier.fit(X, y, eval_set=[(X, y)])
prediction = classifier.predict(X)
assert prediction.shape[0] == kRows and prediction.shape[1] == kCols
assert prediction.ndim == 1
assert prediction.shape[0] == kRows
history = classifier.evals_result()