liveBook · Manning

Early stopping

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

Early stopping is an iterative-training termination criterion that halts optimization when validation performance fails to improve for a specified number of iterations.

Early stopping halts iterative training when validation performance stops improving for a chosen number of iterations. It limits unnecessary optimization, helping gradient-boosted decision trees avoid overfitting while reducing the cost of adding more trees. The same idea also applies to neural-network training. section 5.3.1 section 5.2.1

Set aside part of the training data as a validation set, then evaluate each partial model on a chosen metric. Record the best validation result. Reset the patience counter after an improvement; otherwise increment it. Stop once the counter reaches its limit, or when the maximum planned number of iterations is reached. Training error commonly keeps falling while validation error reaches a favorable point and can then worsen. section 5.3.1

Figure 5.8 A process flow chart describing how early stopping works in GBDTs

Use the flow chart to follow the validation check, patience count, and stop-or-continue decision at every boosting iteration. section 5.3.1

Choose the stopping setup deliberately:

  • Validation fraction reserves training examples for monitoring. In a GradientBoostingClassifier, validation_fraction=0.2 supplies that held-out portion. section 5.3.1
  • Patience determines tolerated non-improving iterations. Scikit-learn uses n_iter_no_change; XGBoost uses early_stopping_rounds; TabNet uses patience. section 5.3.1 section 5.4.4
  • Evaluation metric determines what counts as improvement. XGBoost can use default or selected metrics, and its eval_set identifies the data monitored during fitting. section 5.4.4
  • LightGBM callbacks can tighten the rule with min_delta and select whether only the first metric is considered. section 5.5.3

Stopping a tabular-data boosting run

For a GradientBoostingClassifier, allow up to 1,000 trees but reserve 20% of the training data and stop after 10 non-improving iterations. In the illustrated cross-validation run, early stopping selected substantially fewer trees across folds and reduced mean fit time from 16.48 to 6.24 seconds while the reported accuracy remained 0.826. Use a separate validation split when fitting XGBoost, pass it through eval_set, and let the recorded best iteration drive prediction. section 5.3.1 section 5.4.4

Early stopping complements, rather than replaces, other controls on model complexity. Tree-depth limits, leaf-size constraints, row or column subsampling, and pruning address the complexity of individual trees or the ensemble; early stopping decides when further boosting no longer benefits validation performance. Reserving validation data creates a trade-off: fewer examples remain for fitting, which can affect the final result. section 5.3 section 5.4.4

Implementations differ, but the operating pattern remains the same: monitor a held-out metric, wait through limited non-improvement, retain the best iteration, and stop. XGBoost automatically records and uses its best iteration at prediction time; LightGBM stores best_iteration and also uses it for prediction. A TabNet run can continue to its maximum epochs when validation accuracy never exhausts the configured patience. section 5.4.4 section 5.5.3 section 8.3.1

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Explains the validation, metric, patience, and stopping workflow, then compares Scikit-learn, XGBoost, LightGBM, and TabNet settings.
Examples
Uses Airbnb NYC classification, GradientBoostingClassifier, XGBClassifier, LGBMClassifier, and TabNet training configurations.
What it assumes
Assumes familiarity with iterative model fitting and validation performance while defining patience and the stopping procedure directly.
What you can do after
Operate/configure it in Scikit-learn, XGBoost, LightGBM, and TabNet by selecting validation data, metrics, and patience.
How it connects
Connects gradient boosting, gradient descent, validation metrics, overfitting, decision trees, neural networks, and cross-validation.

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 Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.