Callback Functions
This document gives a basic walkthrough of callback API used in XGBoost Python package. In XGBoost 1.3, a new callback interface is designed for Python package, which provides the flexibility of designing various extension for training. Also, XGBoost has a number of pre-defined callbacks for supporting early stopping, checkpoints etc.
Using builtin callbacks
By default, training methods in XGBoost have parameters like early_stopping_rounds and
verbose/verbose_eval, when specified the training procedure will define the
corresponding callbacks internally. For example, when early_stopping_rounds is
specified, EarlyStopping callback is invoked
inside iteration loop. You can also pass this callback function directly into XGBoost: