### Introduction

Many people, including me, have been using gradient boosting machine (GBM), one of the most popular and powerful machine learning algorithms, to solve machine learning problems without knowing exactly what is going on underneath.

In this article, I will elucidate all the mathematics behind without leaving anything ambiguous.

### Problem Definition

Most of the machine learning problems, including classification and regression problems, could be modeled as

where $\mathbf{x}$ and $y$ are features and label respectively, $L$ is the loss function, $F$ is a function which represents the model, and $F^{\ast}$ is the optimized function.

### Gradient Descent

#### Parameter Space

Suppose $F$ is a parameterized model with parameters $\mathbf{P}$, $F(\mathbf{x};\mathbf{P})$, our optimization goal becomes equivalent to

where

and the optimal model is

We apply gradient descent to optimize the parameters $\mathbf{P}$. Suppose at time step $t-1$, the value of the parameters are $\mathbf{P}_{t-1}$. The gradient of the parameters, $\mathbf{g}_t$, is computed as follows.

where $j$ is the index of the parameter in the model.

The updated parameters at time step $t$ will become

where

Here ${\rho}_{t}$ is a scalar. Usually in machine learning, ${\rho}_{t}$ is arbitrary and is not optimal. To reach good optimization performance, we do linear search for ${\rho}_{t}$, i.e.,

Because ${\rho}_{t}$ is a scalar, so it could not make all the parameters in $\mathbf{P}$ to reach optimal values in one step. To optimize the parameters, we would have to do multiple steps to update. If we unroll the time-series updates, we would have

where $\mathbf{P}_{0}$ is the initialized parameters at time step $0$.

#### Function Space

In stead of doing optimization in parameter space, we could also do optimization in function space. We consider $F(\mathbf{x})$, i.e., the value of function $F$ evaluated at point $\mathbf{x}$, as the parameter to optimize.

Our objective function is

and we define

We assume function $F$ has no constrains, i.e., for any $\mathbf{x}$, $F(\mathbf{x})$ could be any value. Minimizing the above objective function is equivalent to minimizing ${\phi}(F(\mathbf{x}))$ for each $\mathbf{x}$ in the integral interval. Usually, there are infinite number of $\mathbf{x}$, and it is impossible to minimize ${\phi}(F(\mathbf{x}))$ for all $\mathbf{x}$. However, in practice, our training data is finite, so we could do this.

Suppose our training set consists of $N$ data points ${ \mathbf{x} ,y }_{1}^{N}$, the function $F$ could be represented as a discrete function

if $\mathbf{x}$ does not exist in the training data, $F(\mathbf{x})$ is undefined and it could be any value. Also note that $F$ does not have to be differentiable with respect to $\mathbf{x}$.

For each $\mathbf{x}$ from the training set, We compute the derivative of ${\phi}(F(\mathbf{x}))$ with respect to $F(\mathbf{x})$,

So similarly,

We apply gradient descent to optimize $F$. Suppose at time step $t-1$, the value of the parameters are $F_{t-1}$. The gradient of the parameters, $g_t$, is computed as follows.

where

So the updated function $F$ becomes

Similarly, the value of ${\rho}_{t}$ is determined by linear search,

Note that because each data point $\mathbf{x}_i$ in the dataset only has one label $y_i$, i.e., $P(y_i | \mathbf{x}_i) = 1$,

The most frequently used loss function for regression is L2 loss.

The $g_t(\mathbf{x}_i)$ expression for L2 loss becomes

### Gradient Boosting Machine

#### Theory

As we have pointed out, the optimization in functional space directly tunes the value of $F(\mathbf{x})$, and the optimization for $F(\mathbf{x})$ does not dependent on the training data points other than $\mathbf{x}$. So $F$ would be very likely not to generalize well to the data points that have not been shown in the training set.

If we could impose smoothness to $F$ by introducing nearby data points when tuning the value of $F(\mathbf{x})$, $F$ is likely to generalize better.

So instead of updating $F$ using discrete function $g$ which has no smoothness at all, we use another smooth function $h$ such that $h(\mathbf{x})$ is close to $g(\mathbf{x})$ for $x \in {{\mathbf{x}_{i}}}_{1}^{N}$. In order to make $h$ smooth, we need to use all the data points from training set ${{\mathbf{x}_{i}}}_{1}^{N}$ to fit the parameters for $h$.

Concretely, we create a new model $h(\mathbf{x}; \mathbf{a}_t)$ at each time step $t$. The update of function $F$ becomes

Because $h(\mathbf{x}; \mathbf{a}_t)$ is a smoothing version of $-g_{t}(\mathbf{x})$, therefore, we use $(\mathbf{x}_i, g_{t}(\mathbf{x}_i))$, $x \in {{\mathbf{x}_{i}}}_{1}^{N}$, as the train set to fit $h(\mathbf{x}; \mathbf{a}_t)$ using L2 loss.

Note that $h(\mathbf{x}; \mathbf{a}_t)$ is parameterized and smoothed by fitting using all data points from the train set. Sometimes, $-g_t(\mathbf{x}_i)$ is also denoted as $\tilde{y}_i$, and $\tilde{y}_i$ is called “pseudo-response”.

The constant $\rho_t$ could be computed using linear search.

Therefore, gradient boosting machine is nothing special but using a parametric smoothing function $h(\mathbf{x}_i; \mathbf{a}_t))$ to replace the discrete non-parametric gradient function $g_t(\mathbf{x})$ during the machine learning optimization in the function space. In each time step, we introduce a new model, which is called “boost”.