liveBook · Manning

Early stopping

As explained in Ensemble Methods for Machine Learning

Early stopping is a boosting technique that terminates training after enough base estimators have been added to achieve acceptable validation performance.

Early stopping limits the size of a sequential ensemble by ending training when adding more base estimators no longer improves validation performance. It controls growing ensemble complexity before it overfits, while also avoiding unnecessary training work. section 5.4.2 section 4.3.2

Set a maximum ensemble size, reserve a validation set, choose a metric, and evaluate after each boosting iteration. Training continues while the score improves; if it fails to improve for a chosen patience window, or number of early-stopping rounds, training terminates. The validation set and metric are explicit parts of the decision, not afterthoughts. section 5.4.2 section 6.4.2

A five-round patience window

Suppose an ensemble allows 500 estimators and uses five early-stopping rounds. Monitor validation error as trees are added. Once no validation improvement appears across five consecutive iterations, stop rather than building all 500 trees. In a LightGBM run scored by AUC, the best iteration can be retained even though later rounds were attempted. section 5.4.2

Listing 5.6 Early stopping with LightGBM
from sklearn.model_selection import train_test_split
Xtrn, Xval, ytrn, yval = train_test_split(
                             X, y, test_size=0.2,               #1
                             shuffle=True, random_state=42)
                                          
 
gbm = LGBMClassifier(boosting_type='gbdt', n_estimators=50, 
                     max_depth=1, early_stopping=5)             #2
 
gbm.fit(Xtrn, ytrn, 
        eval_set=[(Xval, yval)], eval_metric='auc')             #3

This implementation splits training and validation data, sets an ensemble limit and patience value, then supplies the validation set and AUC metric to LightGBM. section 5.4.2

Early stopping is related to, but distinct from, other controls on boosting complexity:

  • Learning rate is proactive: it slows how quickly the ensemble learns. Early stopping is reactive: it ends training when validation behavior indicates a sufficiently good model or emerging overfitting. section 5.4 section 6.4
  • Pre-pruning stops before a large ensemble is fitted. Post-pruning first trains a large AdaBoost ensemble, then removes weak learners with weights below a selected threshold. section 4.3.2
  • The same validation-driven pattern appears in LightGBM, XGBoost, and CatBoost; each adds one tree per iteration and exposes an early-stopping-rounds setting. section 5.4.2 section 6.4.2 section 8.2.3

How Ensemble Methods for Machine Learning covers it

How deep it goes
Explains validation-based patience step by step and implements it in LightGBM and XGBoost, without deriving boosting internals.
Examples
Uses decision-stump ensemble searches, AUC-monitored LightGBM and XGBoost runs, and CatBoost evaluation curves on credit data.
What it assumes
Assumes boosted ensembles, base estimators, validation performance, and evaluation metrics; reinforces their role in selecting ensemble size.
What you can do after
Apply it via LightGBM, XGBoost, or CatBoost by providing an evaluation set, metric, maximum iterations, and patience window.
How it connects
Connects early stopping to learning rate, cross-validation, validation sets, AUC, AdaBoost, LightGBM, XGBoost, and CatBoost.

Also explained in

Compare how 9 books explain early stopping →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.