Adaboost.M1¶
Adaboost.M1¶
The convention is \(N\) is the number of training examples and \(M\) is the number of trees.
We consider the two class problem for simpler analysis, and denote them by \(Y \in \{-1, 1 \}\). The error rate is defined as
and if the error rate is near \(0.5\), then the classifier is no better than a random guess.
Boosting builds trees in a sequential manner, and outputs of all the trees are weighted to get the final output from the classifier
where we build a total of \(M\) trees and \(G_{m}\) is a weak clasifier.
At each step, data weights are recalculated. Observations misclassified at the last step receive higher weight and vice versa. To start off, all observations receive the same weight \(1/N\).
Basic Algorithm¶
-
Initialize the weights of all observations as \(w_{i} = \cdots = w_{n} = 1/N\)
-
For \(m = 1\) to \(M\)
-
Fit a classifier \(G_{m}(x)\) to the training data with weights \(w_{i}\)
-
Compute weighted error
\[ \begin{aligned} err_{m} = \frac{\sum_{i=1}^{N} w_{i} I(y_{i} \neq G_{m}(x_{i}))}{\sum_{i=1}^{N} w_{i}} \\quad \text{(1)} \end{aligned} \] -
Compute tree weight
\[ \begin{aligned} \alpha_{m} = log \left( \frac{1 - err_{m}}{err_{m}} \right) \quad \text{(2)} \end{aligned} \] -
Update the observation weights as
\[ \begin{aligned} w_{i} \leftarrow w_{i} \cdot exp(\alpha_{m} \cdot I(y_{i} \neq G_{m}(x)), i = 1, \ldots, n \quad \text{(3)} \end{aligned} \]
-
-
Output the final classifier output \(\sum_{m=1}^{M} \alpha_{m}G_{m}(x)\)
Note that the algorithm here returns discrete classes and is called Discrete Adaboost.
Forward Stagewise Additive Modelling¶
The boosting algorithm is one solution to a more general set of problems
where \(L(y, f(x))\) is a loss function (log likelihood or squared error) averaged over the data and \(b(x; \gamma_{m})\) is a basis function that maps the input vector to a scalar. \(\gamma_{m}\) is a set of parameters, which can be parameters of a decision tree like depth, number of nodes and samples in a node.
The above loss function is difficult to directly minimize for a set of basis functions. Instead, the simpler problem to solve is
The general algorith then is
-
Initialize \(f_{0}(x) = 0\)
-
for \(m = 1\) to \(M\)
-
Compute the parameters
\[ \begin{aligned} \beta_{m}, \gamma_{m} = \argmin_{\beta, \gamma} \sum_{i=1}^{N} L(y_{i}, f_{m-1}(x_{i}) + \beta b(x_{i}; \gamma)) \end{aligned} \] -
Update \(f_{m}(x) = f_{m-1}(x) + \beta_{m}b(x;\gamma_{m})\)
-
In the case of regression, the above formulation with least squares loss becomes
which means we are fitting the new basis function on the residuals of the previous formulation. Though this loss is good for regression, we need different loss function for a classification problem.
Exponential Loss¶
Using the class indicators as \(Y \in \{-1, 1 \}\), we show that AdaBoost.M1 uses exponential loss to build the stagewise additive model
The weights keep changing with each iteration. We can rewrite the last equation as
Hence, the recursive \(f(x)\) and \(w(x)\) update becomes
which is similar to the form obtained in equation (3) with an added constant \(exp(-\beta_{m})\) same across all the data points and hence makes no difference. The probability of prediction of the classes then becomes
meaning the output that is the sign of the function is sign of log likelihood and thus justified.