The approx tree method uses the basic `DMatrix` (not recommended).
(it: Iterator)
| 154 | |
| 155 | |
| 156 | def approx_train(it: Iterator) -> None: |
| 157 | """The approx tree method uses the basic `DMatrix` (not recommended).""" |
| 158 | |
| 159 | # For non-data arguments, specify it here once instead of passing them by the `next` |
| 160 | # method. |
| 161 | Xy = xgboost.DMatrix(it, missing=np.nan, enable_categorical=False) |
| 162 | # ``approx`` is also supported, but less efficient due to sketching. It's |
| 163 | # recommended to use `hist` instead. |
| 164 | booster = xgboost.train( |
| 165 | {"tree_method": "approx", "max_depth": 4, "device": it.device}, |
| 166 | Xy, |
| 167 | evals=[(Xy, "Train")], |
| 168 | num_boost_round=10, |
| 169 | ) |
| 170 | booster.predict(Xy) |
| 171 | |
| 172 | |
| 173 | def main(work_dir: str, cli_args: argparse.Namespace) -> None: |