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

Method test_DMatrix_save_to_path

tests/python/test_basic.py:294–304  ·  view source on GitHub ↗

Saving to a binary file using pathlib from a DMatrix.

(self, tmp_path: Path)

Source from the content-addressed store, hash-verified

292 assert dtrain.num_col() == 127
293
294 def test_DMatrix_save_to_path(self, tmp_path: Path) -> None:
295 """Saving to a binary file using pathlib from a DMatrix."""
296 data = np.random.randn(100, 2)
297 target = np.array([0, 1] * 50)
298 features = ["Feature1", "Feature2"]
299
300 dm = xgb.DMatrix(data, label=target, feature_names=features)
301
302 binary_path = tmp_path / "dtrain.bin"
303 dm.save_binary(binary_path)
304 assert binary_path.exists()
305
306 def test_Booster_init_invalid_path(self):
307 """An invalid model_file path should raise XGBoostError."""

Callers

nothing calls this directly

Calls 2

save_binaryMethod · 0.95
DMatrixMethod · 0.45

Tested by

no test coverage detected