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

Function run_basic_predict

python-package/xgboost/testing/ordinal.py:322–335  ·  view source on GitHub ↗

Enable tests with mixed devices.

(DMatrixT: Type, device: Device, tdevice: Device)

Source from the content-addressed store, hash-verified

320
321
322def run_basic_predict(DMatrixT: Type, device: Device, tdevice: Device) -> None:
323 """Enable tests with mixed devices."""
324 enc, reenc, encoded, y = _basic_example(device)
325
326 Xy = DMatrixT(enc, y, enable_categorical=True)
327 booster = train({"device": tdevice}, Xy, num_boost_round=4)
328
329 predt0 = booster.inplace_predict(reenc)
330 predt1 = booster.inplace_predict(encoded)
331 assert_allclose(device, predt0, predt1)
332
333 fmat = DMatrixT(reenc, enable_categorical=True)
334 predt2 = booster.predict(fmat)
335 assert_allclose(device, predt0, predt2)
336
337
338def run_cat_predict(device: Device) -> None:

Callers 2

test_mixed_devices_typesFunction · 0.90
run_cat_predictFunction · 0.85

Calls 5

trainFunction · 0.90
_basic_exampleFunction · 0.85
assert_allcloseFunction · 0.85
inplace_predictMethod · 0.45
predictMethod · 0.45

Tested by 1

test_mixed_devices_typesFunction · 0.72