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

Function train

tests/python/test_with_sklearn.py:109–121  ·  view source on GitHub ↗
(booster: str, forest: Optional[int])

Source from the content-addressed store, hash-verified

107 X, y = load_iris(return_X_y=True)
108
109 def train(booster: str, forest: Optional[int]) -> None:
110 rounds = 4
111 cls = xgb.XGBClassifier(
112 n_estimators=rounds,
113 num_parallel_tree=forest,
114 booster=booster,
115 early_stopping_rounds=3,
116 ).fit(X, y, eval_set=[(X, y)])
117 assert cls.best_iteration == rounds - 1
118
119 # best_iteration is used by default, assert that under gblinear it's
120 # automatically ignored due to being 0.
121 cls.predict(X)
122
123 num_parallel_tree = 4
124 train("gbtree", num_parallel_tree)

Callers 1

test_best_iterationFunction · 0.70

Calls 2

fitMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected