Fix multi-output with alternating strategies. (#9933)
--------- Co-authored-by: Philip Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
@@ -394,3 +394,14 @@ def train_result(
|
||||
assert booster.feature_types == dmat.feature_types
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class ResetStrategy(xgb.callback.TrainingCallback):
|
||||
"""Callback for testing multi-output."""
|
||||
|
||||
def after_iteration(self, model: xgb.Booster, epoch: int, evals_log: dict) -> bool:
|
||||
if epoch % 2 == 0:
|
||||
model.set_param({"multi_strategy": "multi_output_tree"})
|
||||
else:
|
||||
model.set_param({"multi_strategy": "one_output_per_tree"})
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user