Using early stopping¶
If overfitting occurs, t-boost can stop the training earlier than the training parameters dictate. For example, it can be stopped before the specified number of trees are built. Early stopping is turned on by default. See Early stopping for how it works.
Python package¶
The following parameters can be set in the constructor of the TBoostRegressor and TBoostClassifier classes and are used when the model is trained:
validation_fraction- The fraction of the training objects each bag sets aside as its validation dataset (0.1).
Noneturns early stopping off. early_stopping_rounds- The number of iterations to continue the training after the iteration with the optimal metric value (500).
early_stopping_adaptive- Makes the number of iterations to wait grow with the iteration of the best result (1.5).
early_stopping_min_delta- The minimum relative improvement of the metric for an iteration to become the new best (0.0001).
See Early stopping settings for details.
The following parameter can be set for the fit method:
callbacks- Functions called after every iteration of every bag, which can stop that bag.
Usage examples¶
from t_boost import TBoostRegressor
model = TBoostRegressor(objective="poisson")
model.fit(train_data, "ClaimCount", exposure="Exposure")
print(model.n_trees_per_bag_) # the trees each bag kept
print(model.stopping_reason_per_bag_) # why each bag stopped
deviance = model.evals_result_["eval"]["deviance"] # one curve per bag