../ Data Science
-rw-r--r--aguang2.7 KiB2 min read

Adaptive Boosting Algorithm

Adaptive Boosting (AdaBoost) is an ensembled machine learning algorithm. The key idea is:

  • Improving the weights of mis-classified instances.
  • Voting by a sort of weak classifiers can lead to a strong classifier.
  • Better weak classifiers should have greater weights to vote.

AdaBoost is sensitive to noisy data and outliers.

Input

  • Train instances: T={(x1,y1),(x2,y2),⋯ ,(xN,yN)}T = \{ (x_1, y_1), (x_2, y_2),\cdots,(x_N, y_N) \}, where NN is the number of instances, xi∈Rnx_i \in R^n, yi∈{−1,+1}y_i \in \{ -1, +1 \}, i=1,2,⋯ ,Ni = 1,2,\cdots,N, nn is the number of features.
  • Weak binary classifiers: H={h1,h2,⋯ ,hM}H = \{ h_1, h_2,\cdots,h_M \}, where MM is the number of classifiers, hi(x)∈{−1,+1}h_i(x) \in \{-1, +1 \}, i=1,2,⋯ ,Mi = 1,2,\cdots,M.
  • Max iteration times KK.

Output

  • A strong binary classifier G(x)=sgn(∑i=1Naihi(x))G(x) = sgn(\sum_{i = 1}^{N} a_{i} h_i(x)), where

    sgn(x)={+1x≥0−1x≥0sgn(x) = \begin{cases} +1 & x \geq 0 \\ -1 & x \geq 0 \\ \end{cases}

    aia_i is the weights of weak classifiers.

Pseudo Code

AdaBoost(K,X,Y,H)Initialize weights of instances D=[d1,1d1,2⋯d1,Nd2,1d2,2⋯d2,N⋮⋮⋱⋮dM,1dM,2⋯dM,N]←[1N1N⋯1N1N1N⋯1N⋮⋮⋱1N1N1N⋯1N]Repeat K times:for hi∈H:Train hi using X,Y with DError rate ei=1N∑j=1NP(hi(xj)≠yj)Weights of classifiers ai=12log1−eieiUpdate weights of instances di,j←{di,j×e−aihi(xj)=yjdi,j×eaihi(xj)≠yjNormalize weights of instances di,j←di,j∑j=1Ndi,jreturn G(x)=sgn(∑i=1Naihi(x))\begin{aligned} & AdaBoost(K, X, Y, H) \\ & \quad \mathtt{Initialize\ weights\ of\ instances\ } D = \begin{bmatrix} d_{1, 1} & d_{1, 2} & \cdots & d_{1, N} \\ d_{2, 1} & d_{2, 2} & \cdots & d_{2, N} \\ \vdots & \vdots & \ddots & \vdots \\ d_{M, 1} & d_{M, 2} & \cdots & d_{M, N} \\ \end{bmatrix} \leftarrow \begin{bmatrix} \frac{1}{N} & \frac{1}{N} & \cdots & \frac{1}{N} \\ \frac{1}{N} & \frac{1}{N} & \cdots & \frac{1}{N} \\ \vdots & \vdots & \ddots & \frac{1}{N} \\ \frac{1}{N} & \frac{1}{N} & \cdots & \frac{1}{N} \\ \end{bmatrix}\\ & \quad \mathtt{Repeat}\ K\ \mathtt{times} :\\ & \quad \quad \mathtt{for}\ h_i \in H :\\ & \quad \quad \quad \mathtt{Train\ } h_i \mathtt{\ using\ } X, Y \mathtt{\ with\ } D\\ & \quad \quad \quad \mathtt{Error\ rate\ } e_i = \frac{1}{N} \sum_{j = 1}^N P(h_i(x_j) \neq y_j)\\ & \quad \quad \quad \mathtt{Weights\ of\ classifiers\ } a_i = \frac{1}{2} log \frac{1 - e_i}{e_i}\\ & \quad \quad \mathtt{Update\ weights\ of\ instances\ }d_{i,j} \leftarrow \begin{cases} d_{i,j} \times e^{-a_i} & h_i(x_j) = y_j \\ d_{i,j} \times e^{a_i} & h_i(x_j) \neq y_j \\ \end{cases} \\ & \quad \quad \mathtt{Normalize\ weights\ of\ instances\ } d_{i,j} \leftarrow \frac{d_{i,j}}{\sum_{j = 1}^{N} d_{i,j}}\\ & \quad \mathtt{return }\ G(x) = sgn(\sum_{i = 1}^{N} a_{i} h_i(x)) \\ & \end{aligned}

References

COMMAND INTERFACE

↑ ↓ navigate · Enter execute · Esc exit · try “whoami”

Loading filesystem…

:help aguang.xyz

A personal website disguised as an operating system.

Ctrl / Cmd + K
Command palette + full-text search
Tab / Shift + Tab
Move between links and controls
Enter
Open a focused link or search result
↑ / ↓ in search
Navigate search results
In a directory filter
Enter/Done or ↓ focuses a result; Esc clears the filter
Esc
Clear a search or close a window