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

Function approx_train

demo/guide-python/external_memory.py:156–170  ·  view source on GitHub ↗

The approx tree method uses the basic `DMatrix` (not recommended).

(it: Iterator)

Source from the content-addressed store, hash-verified

154
155
156def 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
173def main(work_dir: str, cli_args: argparse.Namespace) -> None:

Callers 1

mainFunction · 0.85

Calls 3

DMatrixMethod · 0.45
trainMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected