(booster: str, forest: Optional[int])
| 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) |
no test coverage detected