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

Lesson 26

XGBoost Regressor

Boost a numeric model with second-order steps and regularization, so each tree moves the prediction by a controlled amount.

Intermediate12 min
XGBoost Regressor MahiDev

What You Will Learn

  • Idea
  • Example
  • When to use it

Idea

XGBoost is gradient boosting with two extra controls. It uses the slope and the curvature of the loss, and it penalizes leaf weights. For squared error the curvature is 1, so one step is a fraction of the current error, pointed so the prediction moves toward the target.

Example

python
grad = 2.0
hess = 1.0
learning_rate = 0.1
step = learning_rate * (-grad / hess)
print(f"prediction change: {step:.2f}")

Output:

text
prediction change: -0.20

When to use it

  • Use it for structured numeric tables when boosting is the right family.
  • The step above is one leaf update, not a full training run.
  • Regularization on the leaves is the main difference from plain gradient boosting.

Loading playground…