MCPcopy Create free account
hub / github.com/dmlc/xgboost / test_load_pkl

Method test_load_pkl

tests/python-gpu/load_pickle.py:15–29  ·  view source on GitHub ↗

Test whether prediction is correct.

(self)

Source from the content-addressed store, hash-verified

13
14class TestLoadPickle:
15 def test_load_pkl(self) -> None:
16 """Test whether prediction is correct."""
17 assert os.environ["CUDA_VISIBLE_DEVICES"] == "-1"
18 bst = load_pickle(model_path)
19 x, y = build_dataset()
20 if isinstance(bst, xgb.Booster):
21 test_x = xgb.DMatrix(x)
22 res = bst.predict(test_x)
23 else:
24 res = bst.predict(x)
25 assert len(res) == 10
26 bst.set_params(n_jobs=1) # triggers a re-configuration
27 res = bst.predict(x)
28
29 assert len(res) == 10
30
31 def test_context_is_removed(self) -> None:
32 """Under invalid CUDA_VISIBLE_DEVICES, context should reset"""

Callers

nothing calls this directly

Calls 5

load_pickleFunction · 0.90
build_datasetFunction · 0.90
DMatrixMethod · 0.45
predictMethod · 0.45
set_paramsMethod · 0.45

Tested by

no test coverage detected