How is the optimal leaf weight and the split gain derived in XGBoost's second-order objective? How do you apply it to 6 samples with logistic loss, current prediction (so ), labels in the left candidate leaf and in the right, , ?
Supervised learning, XGBoost
Level L4 Advanced. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can derive the second-order leaf objective and compute a split gain with gradients and Hessians.
Key idea
Using and , a leaf's loss is , with and . It is minimised at with value .
Steps
- Expand the loss to second order around the current prediction: . Add the penalty for leaves.
- Group by leaf : the objective is . Setting the derivative to zero gives and a leaf score of .
- The gain of a split is the old leaf score minus the new ones: .
- Logistic loss: and . At : for all, and for label 1, for label 0.
- Left : , . Right : , . Parent: , .
- Gain , so keep the split.
- Leaf weights: and (before the learning rate). The left leaf, with mostly positives, moves the score up.
Common mistakes
- Forgetting the sign in .
- Forgetting that is added to in every denominator, including the parent's .
- Leaving out , which sets the minimum gain required to split.
How long your answer should be
One page; 7–8 minutes.
Last checked on 4 December 2026.
Read this
Previous in Supervised learning: Describe how partial least squares (PLS) builds its first component, and how it differs from principal components regression (PCR). Take centred with , for samples: what are the first PLS direction and the one-component fit coefficients, and how do they compare with OLS?
Next in Supervised learning: A random forest has features (a truly informative binary variable) and (a continuous pure-noise variable). Why can mean decrease in impurity (MDI) rate as important, and how does permutation importance on the out-of-bag (OOB) data fix this? What is its own weakness with correlated features?