@@ -999,6 +999,7 @@ def fit(self, X, y, sample_weight=None, bags=None, init_score=None):
999999 delayed (booster )(
10001000 shm_name = shm_name ,
10011001 bag_idx = idx ,
1002+ stage = 0 ,
10021003 callback = callback ,
10031004 dataset = (
10041005 shared .name if shared .name is not None else shared .dataset
@@ -1238,6 +1239,7 @@ def fit(self, X, y, sample_weight=None, bags=None, init_score=None):
12381239 delayed (booster )(
12391240 shm_name = shm_name ,
12401241 bag_idx = idx ,
1242+ stage = 1 ,
12411243 callback = callback ,
12421244 dataset = (
12431245 shared .name
@@ -1349,6 +1351,7 @@ def fit(self, X, y, sample_weight=None, bags=None, init_score=None):
13491351 exception , intercept_change , _ , _ , rng = booster (
13501352 shm_name = None ,
13511353 bag_idx = 0 ,
1354+ stage = - 1 ,
13521355 callback = None ,
13531356 dataset = shared .dataset ,
13541357 intercept_rounds = develop .get_option ("n_intercept_rounds_final" ),
@@ -3206,13 +3209,15 @@ class EBMModel(BaseEBM):
32063209 tradeoff for the ensemble of models --- not the individual models --- a small
32073210 amount of overfitting of the individual models can improve the accuracy of
32083211 the ensemble as a whole.
3209- callback : Optional[Callable[[int, int, bool, float], bool]], default=None
3210- A user-defined function that is invoked at the end of each boosting step to determine
3211- whether to terminate boosting or continue. If it returns True, the boosting loop is
3212- stopped immediately. By default, no callback is used and training proceeds according
3213- to the early stopping settings. The callback function receives:
3214- (1) the bag index, (2) the number of boosting steps completed,
3215- (3) a boolean indicating whether progress was made in the current step, and (4) the current best score.
3212+ callback : Optional[Callable[..., bool]], default=None
3213+ A user-defined function invoked after each progressing boosting step. Must use
3214+ keyword-only arguments: ``def my_callback(*, bag, stage, step, term, metric)``.
3215+ If it returns True, boosting is stopped immediately.
3216+ The callback receives: ``bag`` (int) the outer bag index,
3217+ ``stage`` (int) the boosting stage (0=mains, 1=pairs),
3218+ ``step`` (int) the number of boosting steps completed,
3219+ ``term`` (int) the index of the term that was just boosted,
3220+ and ``metric`` (float) the current validation metric.
32163221 min_samples_leaf : int, default=4
32173222 Minimum number of samples allowed in the leaves.
32183223 min_hessian : float, default=0.0
@@ -3309,7 +3314,7 @@ def __init__(
33093314 max_rounds : Optional [int ] = 50000 ,
33103315 early_stopping_rounds : Optional [int ] = 100 ,
33113316 early_stopping_tolerance : Optional [float ] = 1e-5 ,
3312- callback : Optional [Callable [[ int , int , bool , float ] , bool ]] = None ,
3317+ callback : Optional [Callable [... , bool ]] = None ,
33133318 # Trees
33143319 min_samples_leaf : Optional [int ] = 4 ,
33153320 min_hessian : Optional [float ] = 0.0 ,
@@ -3572,13 +3577,15 @@ class EBMClassifier(EBMClassifierMixin, EBMModel):
35723577 tradeoff for the ensemble of models --- not the individual models --- a small
35733578 amount of overfitting of the individual models can improve the accuracy of
35743579 the ensemble as a whole.
3575- callback : Optional[Callable[[int, int, bool, float], bool]], default=None
3576- A user-defined function that is invoked at the end of each boosting step to determine
3577- whether to terminate boosting or continue. If it returns True, the boosting loop is
3578- stopped immediately. By default, no callback is used and training proceeds according
3579- to the early stopping settings. The callback function receives:
3580- (1) the bag index, (2) the number of boosting steps completed,
3581- (3) a boolean indicating whether progress was made in the current step, and (4) the current best score.
3580+ callback : Optional[Callable[..., bool]], default=None
3581+ A user-defined function invoked after each progressing boosting step. Must use
3582+ keyword-only arguments: ``def my_callback(*, bag, stage, step, term, metric)``.
3583+ If it returns True, boosting is stopped immediately.
3584+ The callback receives: ``bag`` (int) the outer bag index,
3585+ ``stage`` (int) the boosting stage (0=mains, 1=pairs),
3586+ ``step`` (int) the number of boosting steps completed,
3587+ ``term`` (int) the index of the term that was just boosted,
3588+ and ``metric`` (float) the current validation metric.
35823589 min_samples_leaf : int, default=4
35833590 Minimum number of samples allowed in the leaves.
35843591 min_hessian : float, default=1e-4
@@ -3734,7 +3741,7 @@ def __init__(
37343741 max_rounds : Optional [int ] = 50000 ,
37353742 early_stopping_rounds : Optional [int ] = 100 ,
37363743 early_stopping_tolerance : Optional [float ] = 1e-5 ,
3737- callback : Optional [Callable [[ int , int , bool , float ] , bool ]] = None ,
3744+ callback : Optional [Callable [... , bool ]] = None ,
37383745 # Trees
37393746 min_samples_leaf : Optional [int ] = 4 ,
37403747 min_hessian : Optional [float ] = 1e-4 ,
@@ -3876,13 +3883,15 @@ class EBMRegressor(EBMRegressorMixin, EBMModel):
38763883 tradeoff for the ensemble of models --- not the individual models --- a small
38773884 amount of overfitting of the individual models can improve the accuracy of
38783885 the ensemble as a whole.
3879- callback : Optional[Callable[[int, int, bool, float], bool]], default=None
3880- A user-defined function that is invoked at the end of each boosting step to determine
3881- whether to terminate boosting or continue. If it returns True, the boosting loop is
3882- stopped immediately. By default, no callback is used and training proceeds according
3883- to the early stopping settings. The callback function receives:
3884- (1) the bag index, (2) the number of boosting steps completed,
3885- (3) a boolean indicating whether progress was made in the current step, and (4) the current best score.
3886+ callback : Optional[Callable[..., bool]], default=None
3887+ A user-defined function invoked after each progressing boosting step. Must use
3888+ keyword-only arguments: ``def my_callback(*, bag, stage, step, term, metric)``.
3889+ If it returns True, boosting is stopped immediately.
3890+ The callback receives: ``bag`` (int) the outer bag index,
3891+ ``stage`` (int) the boosting stage (0=mains, 1=pairs),
3892+ ``step`` (int) the number of boosting steps completed,
3893+ ``term`` (int) the index of the term that was just boosted,
3894+ and ``metric`` (float) the current validation metric.
38863895 min_samples_leaf : int, default=4
38873896 Minimum number of samples allowed in the leaves.
38883897 min_hessian : float, default=0.0
@@ -4039,7 +4048,7 @@ def __init__(
40394048 max_rounds : Optional [int ] = 50000 ,
40404049 early_stopping_rounds : Optional [int ] = 100 ,
40414050 early_stopping_tolerance : Optional [float ] = 1e-5 ,
4042- callback : Optional [Callable [[ int , int , bool , float ] , bool ]] = None ,
4051+ callback : Optional [Callable [... , bool ]] = None ,
40434052 # Trees
40444053 min_samples_leaf : Optional [int ] = 4 ,
40454054 min_hessian : Optional [float ] = 0.0 ,
0 commit comments