Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Lesson 34

XGBoost Classifier

Boost a classifier with curvature-aware leaf weights and regularization, so each added tree is a controlled correction. One example is on this page.

Intermediate12 min
XGBoost Classifier MahiDev

What You Will Learn

  • Idea
  • Example
  • When to use it

Idea

An XGBoost classifier uses the same boosting loop as gradient boosting. The leaf weight comes from the gradient and the hessian of the class loss, then a penalty keeps that weight small. The result is a probability that moves a little after every tree.

Example

python
grad = 0.4
hess = 0.2
learning_rate = 0.1
step = learning_rate * (-grad / (hess + 1.0))
print(f"log-odds change: {step:.3f}")

Output:

text
log-odds change: -0.033

When to use it

  • Use it on tabular classification when you can tune depth, learning rate, and the leaf penalty.
  • The number above is one regularized leaf step, with an extra 1 in the denominator as the penalty.
  • Missing values and column subsampling are built in. They do not replace a clean train and test split.

Loading playground…