Saving to a binary file using pathlib from a DMatrix.
(self, tmp_path: Path)
| 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.""" |
nothing calls this directly
no test coverage detected