Overview of XGBoost Algorithm
XGBoost (Extreme Gradient Boosting) is a powerful machine learning algorithm based on gradient boosting, which is used for both classification and regression problems. It is highly efficient, flexible, and portable, making it a popular choice in machine learning competitions and real-world applications.
Key Features of XGBoost
- Parallel Processing: XGBoost parallelizes the tree construction, making it much faster.
- Regularization: It includes L1 (Lasso) and L2 (Ridge) regularization to reduce overfitting.
- Handling Missing Values: XGBoost can automatically learn what to do with missing values.
- Tree Pruning: Instead of a pre-pruning step, it uses post-pruning, which allows for more accurate models.
- Weighted Quantile Sketch: XGBoost has an efficient way of handling weighted data, making it effective for various problems.
Formula
XGBoost builds decision trees in a sequential manner. The model can be expressed as:
[
\hat{y} = \sum_{k=1}^{K} f_k(x)
]
Where:
- ( \hat{y} ) is the predicted value.
- ( K ) is the number of trees.
- ( f_k(x) ) represents the individual trees built in the sequence.
Loss Function
The objective of XGBoost can be defined as minimizing the loss function:
[
L(y, \hat{y}) + \Omega(f)
]
Where:
- ( L(y, \hat{y}) ) is the loss function (e.g., mean squared error for regression).
- ( \Omega(f) = \gamma T + \frac{1}{2} \lambda \sum_{j=1}^{T} w_j^2 ) is the regularization term, where:
- ( T ) is the number of leaves in the tree.
- ( \gamma ) controls the minimum loss reduction required to make a further partition.
- ( \lambda ) is the L2 regularization term on the weights.
Gradient Boosting Process
- Initialization: Start with a base prediction, often the mean of the target values.
[
\hat{y}_0 = \text{mean}(y)
]
- Iteratively Fit Trees: For each iteration ( k ):
- Compute the pseudo-residuals:
[
r_i^{(k)} = y_i - \hat{y}_{k-1}
]
- Fit a new tree ( f_k ) to the pseudo-residuals.
- Update the predictions:
[
\hat{y}k = \hat{y}{k-1} + \eta f_k(x)
]
Where ( \eta ) is the learning rate.
Visual Representation