The objective it actually minimises
Gradient boosting fits each tree to a gradient. XGBoost writes the whole thing as one objective and includes the tree's own complexity in it.
- : the number of leaves in the tree.
- : the value that leaf outputs.
- : the cost charged per leaf.
- : L2 regularisation on the leaf values.
Regularisation is part of the objective rather than a stopping rule bolted on afterwards, which is the first real difference from plain boosting.
Second order, not first
- : the first derivative of the loss at sample .
- : the second derivative at sample .
Expanding the loss to second order turns each round into a quadratic, and a quadratic can be solved exactly rather than approached by line search.
That is the optimal output for leaf , in closed form, where is the set of samples landing in it.
The gain a split must earn
- : the summed gradients on each side of the split.
- : the summed second derivatives on each side.
Substituting the optimal leaf values back into the objective gives the score of a tree structure, and the difference before and after a split is that gain.
A split is kept only if the gain exceeds , so the term prunes as the tree grows rather than after it.
One round, in order
- Compute and for every training sample under the current prediction.
- Sort each feature and sweep the split points, accumulating and on each side.
- Take the split with the highest gain, and refuse the node entirely if no gain is positive.
- Set each leaf to its closed-form optimal value.
- Add the tree scaled by the learning rate, and move to the next round.
What makes it fast rather than just accurate
Gradient and second derivative for every sample are computed once per round and then only summed, so a split sweep is addition rather than model fitting.
Feature values are pre-sorted into compressed column blocks once, so the sort is not repeated at every node of every tree.
A missing value is not imputed. Each split learns a default direction by trying both and keeping whichever scored better, so sparsity is handled by the algorithm rather than before it.