上一节介绍了Bagging\text{Bagging}Bagging集成学习思想。本节将介绍集成学习思想——Boosting\text{Boosting}Boosting,并介绍经典模型AdaBoost\text{AdaBoost}AdaBoost。
关于Bagging\text{Bagging}Bagging过程主要有两个特点:
Bagging\text{Bagging}Bagging过程优化的是预测模型泛化误差中的方差(Variance\text{Variance}Variance)部分,与泛化误差中的偏差(Bias\text{Bias}Bias)部分无关。并且泛化误差中方差的大小仅与预测过程中,预测模型的自身性质相关。
通常称方差较大的预测模型为不稳定学习器(Unstable Learner\text{Unstable Learner}Unstable Learner)。该类学习器的特点在于:不同的基学习器随着样本的扰动会得到差异度较高的学习结果。最终通过Bagging\text{Bagging}Bagging集成后的泛化性能可通过差异度的增加而进一步提升。
这种基于样本扰动带来的差异性恰恰是Bagging\text{Bagging}Bagging集成思想的要求。甚至我们可以 人为设置 各基学习器之间的差异程度。如随机森林(Random Forest,RF\text{Random Forest,RF}Random Forest,RF)。该算法就是将样本扰动、属性扰动相结合,从而控制学习器之间的差异性:
而划分属性子集的大小,就是人为控制的参数。这种方式是通过‘人工干扰’,故意让模型学的不够准确,使得各学习器之间的差异性明显显现出来,从而更加符合Bagging\text{Bagging}Bagging算法的条件。Boosting\text{Boosting}Boosting算法的核心思路是将一组弱学习器(Weak Learners\text{Weak Learners}Weak Learners)提升为强学习器(Strong Learners\text{Strong Learners}Strong Learners)的算法。相比于Bagging\text{Bagging}Bagging算法的思想,它有如下几点不同之处:
主要将若干个‘不稳定学习器’,也就是预测方差较大的学习器组合成一个‘稳定的学习器’(Stable Learner\text{Stable Learner}Stable Learner);主要将若干个‘弱学习器’,也就是预测偏差较大的学习器组合成一个‘强学习器’。这个强学习器对于样本分布的位置更加准确(偏差较小).关于Boosting\text{Boosting}Boosting算法思想可描述为如下步骤:
可以看作D1\mathcal D_1D1是D\mathcal DD的一个子集, 而D1\mathcal D_1D1内主要包含hinith_{init}hinit预测误差更大样本,而hinith_{init}hinit预测误差小/准确的样本并不做过多关注。Boosting\text{Boosting}Boosting算法系列里面有一些著名样例。如AdaBoost,Gradient Boosting\text{AdaBoost,Gradient Boosting}AdaBoost,Gradient Boosting等。本节对这AdaBoost\text{AdaBoost}AdaBoost算法进行介绍。
AdaBoost\text{AdaBoost}AdaBoost有多种推导方式,这里以加性模型(Additive Model\text{Additive Model}Additive Model)作为基学习器的融合方式进行描述。而加性模型本质上就是各基学习器的线性组合:
H(x)=∑t=1Tαt⋅ht(x)\mathcal H(x) = \sum_{t=1}^{\mathcal T} \alpha_t \cdot h_t(x)H(x)=t=1∑Tαt⋅ht(x)
其中xxx表示具体样本;H(x)\mathcal H(x)H(x)表示融合后的预测模型;ht(x)h_t(x)ht(x)表示ttt时刻训练出的基学习器;αt\alpha_tαt表示基学习器ht(x)h_t(x)ht(x)对应的权重信息;
已知数据集合D={(x(i),y(i))}i=1N\mathcal D = \{(x^{(i)},y^{(i)})\}_{i=1}^ND={(x(i),y(i))}i=1N,其中样本标签y(i)(i=1,2,⋯,N)∈{+1,−1}y^{(i)}(i=1,2,\cdots,N) \in \{+1,-1\}y(i)(i=1,2,⋯,N)∈{+1,−1}。
这明显是一个关于‘二分类问题’的数据集合。
关于模型H(x)\mathcal H(x)H(x)的优化过程,使用的策略是 指数损失函数(Exponential Loss Function\text{Exponential Loss Function}Exponential Loss Function):
Lexp(H∣D)=1N∑i=1Nexp[−f(x(i))⋅H(x(i))]=Ex(i)∼D{exp[−f(x(i))⋅H(x(i))]}\begin{aligned} \mathcal L_{exp}(\mathcal H \mid \mathcal D) & = \frac{1}{N} \sum_{i=1}^N \exp \left[-f(x^{(i)}) \cdot \mathcal H(x^{(i)})\right] \\ & = \mathbb E_{x^{(i)} \sim \mathcal D} \left\{\exp \left[-f(x^{(i)}) \cdot \mathcal H(x^{(i)})\right]\right\} \end{aligned}Lexp(H∣D)=N1i=1∑Nexp[−f(x(i))⋅H(x(i))]=Ex(i)∼D{exp[−f(x(i))⋅H(x(i))]}
其中f(x)f(x)f(x)表示真实函数/真实模型。最终目标是通过调整H(x)\mathcal H(x)H(x)中的权重信息(α1,α2,⋯,αT)(\alpha_1,\alpha_2,\cdots,\alpha_{\mathcal T})(α1,α2,⋯,αT),使得损失函数Lexp(H∣D)\mathcal L_{exp}(\mathcal H \mid \mathcal D)Lexp(H∣D)达到最小:
argmaxα1,⋯,αtLexp(H∣D)\mathop{\arg\max}\limits_{\alpha_1,\cdots,\alpha_t} \mathcal L_{exp}(\mathcal H \mid \mathcal D)α1,⋯,αtargmaxLexp(H∣D)
由于α1,α2,⋯,αT\alpha_1,\alpha_2,\cdots,\alpha_{\mathcal T}α1,α2,⋯,αT均是H(x)\mathcal H(x)H(x)中的项,首先基于损失函数对H(x)\mathcal H(x)H(x)求解偏导:
∂∂H(x)[Lexp(H∣D)]=−f(x)⋅exp{−f(x)⋅H(x)}\frac{\partial}{\partial \mathcal H(x)} \left[\mathcal L_{exp}(\mathcal H \mid \mathcal D)\right] = -f(x) \cdot \exp\{-f(x) \cdot \mathcal H(x)\}∂H(x)∂[Lexp(H∣D)]=−f(x)⋅exp{−f(x)⋅H(x)}
令偏导∂∂H(x)[Lexp(H∣D)]≜0\frac{\partial}{\partial \mathcal H(x)} \left[\mathcal L_{exp}(\mathcal H \mid \mathcal D)\right] \triangleq 0∂H(x)∂[Lexp(H∣D)]≜0,求得H(x)\mathcal H(x)H(x)可表示为如下形式:
exp{−H(x)}⋅P(f(x)=1∣x)+exp{H(x)}⋅P(f(x)=−1∣x)≜0⇒[exp{H(x)}]2⋅P[f(x)=−1∣x]=P[f(x)=1∣x]⇒H(x)=12ln[P(f(x)=1∣x)P(f(x)=−1∣x)]\begin{aligned} & \exp \{-\mathcal H(x)\} \cdot \mathcal P(f(x) = 1 \mid x) + \exp\{\mathcal H(x)\} \cdot \mathcal P(f(x) = -1 \mid x) \triangleq 0 \\ & \Rightarrow \left[\exp\{\mathcal H(x)\}\right]^2 \cdot \mathcal P \left[f(x) = -1 \mid x\right] = \mathcal P [f(x) = 1 \mid x] \\ & \Rightarrow \mathcal H(x) = \frac{1}{2} \ln \left[\frac{\mathcal P(f(x) = 1 \mid x)}{\mathcal P(f(x) = -1 \mid x)}\right] \end{aligned}exp{−H(x)}⋅P(f(x)=1∣x)+exp{H(x)}⋅P(f(x)=−1∣x)≜0⇒[exp{H(x)}]2⋅P[f(x)=−1∣x]=P[f(x)=1∣x]⇒H(x)=21ln[P(f(x)=−1∣x)P(f(x)=1∣x)]
由于在该任务中,预测模型H(x)\mathcal H(x)H(x)同样也是判别模型。令Sign\text{Sign}Sign为指示函数,关于H(x)\mathcal H(x)H(x)的指示函数Sign[H(x)]\text{Sign}[\mathcal H(x)]Sign[H(x)]可表示为:
这里没有考虑P(f(x)=1∣x)=P(f(x)=−1∣x)\mathcal P(f(x) = 1 \mid x) = \mathcal P(f(x) = -1 \mid x)P(f(x)=1∣x)=P(f(x)=−1∣x)的情况。这种情况H(x)=0\mathcal H(x) = 0H(x)=0,随机选择一项即可。
Sign[H(x)]={1H(x)>0⇔P(f(x)=1∣x)>P(f(x)=−1∣x)−1H(x)<0⇔P(f(x)=1∣x)
0 \Leftrightarrow \mathcal P(f(x) = 1 \mid x) > \mathcal P(f(x) = -1 \mid x) \\ -1 \quad \mathcal H(x) < 0 \Leftrightarrow \mathcal P(f(x) = 1 \mid x) < \mathcal P(f(x) = -1 \mid x) \end{cases} \\ & = \mathop{\arg\max}\limits_{y \in \{-1,1\}} \mathcal P(f(x) = y \mid x) \end{aligned}Sign[H(x)]={1H(x)>0⇔P(f(x)=1∣x)>P(f(x)=−1∣x)−1H(x)<0⇔P(f(x)=1∣x)
−1,1}argmaxP(f(x)=y∣x)
由于原本的任务是二分类任务,因而在定义域中它并不是连续的。但如果使用指数损失函数来替代这个分段函数,能够得到相同的效果。这也是指数损失函数的理论意义。
指数损失函数的最大特点就是该函数连续、可微。该函数在迭代获取最优参数起到关键作用。
由于第一个基学习器h1h_1h1是由原始数据D\mathcal DD以及初始数据分布D1(x)\mathcal D_1(x)D1(x)学习得到。以此类推;如果第ttt次迭代得到基学习器ht(x)h_t(x)ht(x)以及对应的权重参数αt\alpha_tαt,那么仅仅该学习器也同样满足指数损失函数最小:
Select αt⇒minLexp[αtht(x)∣Dt]\text{Select }\alpha_t \Rightarrow \min \mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right]Select αt⇒minLexp[αtht(x)∣Dt]
将Lexp[αtht(x)∣Dt]\mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right]Lexp[αtht(x)∣Dt]展开,可表示为如下形式:
Lexp[αtht(x)∣Dt]=Ex∼Dt{exp[−f(x)⋅αtht(x)]}\mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right] = \mathbb E_{x \sim \mathcal D_t} \left\{\exp[-f(x) \cdot \alpha_th_t(x)]\right\}Lexp[αtht(x)∣Dt]=Ex∼Dt{exp[−f(x)⋅αtht(x)]}
观察exp\expexp内的项:−f(x)⋅αtht(x)=−αt⋅f(x)ht(x)-f(x) \cdot \alpha_th_t(x) = -\alpha_t \cdot f(x)h_t(x)−f(x)⋅αtht(x)=−αt⋅f(x)ht(x),其中f(x)ht(x)f(x)h_t(x)f(x)ht(x)表示结果如下:
无论是f(x)f(x)f(x)还是ttt时刻的ht(x)h_t(x)ht(x),它们都描述二分类任务的函数结果:{−1,+1}\{-1,+1\}{−1,+1},因而存在如下两种匹配情况:
f(x)ht(x)={1f(x)=ht(x)−1f(x)≠ht(x)f(x)h_t(x) = \begin{cases} 1 \quad f(x) = h_t(x) \\ -1 \quad f(x) \neq h_t(x) \end{cases}f(x)ht(x)={1f(x)=ht(x)−1f(x)=ht(x)
至此,可以通过指示函数I(⋅)\mathbb I(\cdot)I(⋅)对Lexp[αtht(x)∣Dt]\mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right]Lexp[αtht(x)∣Dt]进行表示:
Lexp[αtht(x)∣Dt]=Ex∼Dt{exp[−αt⋅f(x)ht(x)]}=Ex∼Dt{exp{−αt}⋅I[f(x)=ht(x)]+exp{−αt}⋅I[f(x)≠ht(x)]}=1N∑x∼Dt{exp{−αt}⋅I[f(x)=ht(x)]+exp{−αt}⋅I[f(x)≠ht(x)]}=exp{−αt}⋅Px∼Dt[f(x)=ht(x)]+exp{αt}⋅Px∼Dt[f(x)≠ht(x)]=exp{−αt}⋅(1−ϵt)+exp{αt}⋅ϵt\begin{aligned} \mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right] & = \mathbb E_{x \sim \mathcal D_t} \left\{\exp[-\alpha_t \cdot f(x)h_t(x)]\right\} \\ & = \mathbb E_{x \sim \mathcal D_t}\{\exp\{-\alpha_t\} \cdot \mathbb I[f(x) = h_t(x)] + \exp\{-\alpha_t\} \cdot \mathbb I[f(x) \neq h_t(x)]\} \\ & = \frac{1}{N}\sum_{x \sim \mathcal D_t} \{\exp\{-\alpha_t\} \cdot \mathbb I[f(x) = h_t(x)] + \exp\{-\alpha_t\} \cdot \mathbb I[f(x) \neq h_t(x)]\} \\ & = \exp\{-\alpha_t\} \cdot \mathcal P_{x \sim \mathcal D_t} \left[f(x) = h_t(x)\right] + \exp\{\alpha_t\} \cdot P_{x \sim \mathcal D_t} \left[f(x) \neq h_t(x)\right] \\ & = \exp\{-\alpha_t\} \cdot (1 - \epsilon_t) + \exp\{\alpha_t\} \cdot \epsilon_t \end{aligned}Lexp[αtht(x)∣Dt]=Ex∼Dt{exp[−αt⋅f(x)ht(x)]}=Ex∼Dt{exp{−αt}⋅I[f(x)=ht(x)]+exp{−αt}⋅I[f(x)=ht(x)]}=N1x∼Dt∑{exp{−αt}⋅I[f(x)=ht(x)]+exp{−αt}⋅I[f(x)=ht(x)]}=exp{−αt}⋅Px∼Dt[f(x)=ht(x)]+exp{αt}⋅Px∼Dt[f(x)=ht(x)]=exp{−αt}⋅(1−ϵt)+exp{αt}⋅ϵt
其中ϵt(t=1,2,⋯,T)\epsilon_t(t=1,2,\cdots,\mathcal T)ϵt(t=1,2,⋯,T)描述为:
ϵt\epsilon_tϵt是一个值域是[0,1][0,1][0,1]的值,它表示属于数据集Dt\mathcal D_tDt满足f(x)≠ht(x)f(x) \neq h_t(x)f(x)=ht(x)的样本xxx的数量占据数据集Dt\mathcal D_tDt总体数量的比例。
ϵt=Px∼Dt[f(x)≠ht(x)]=∑[f(x)≠ht(x)]x∼DtN\begin{aligned} \epsilon_t & = \mathcal P_{x \sim \mathcal D_t} [f(x) \neq h_t(x)] \\ & = \frac{\sum [f(x) \neq h_t(x)]_{x \sim \mathcal D_t}}{N} \end{aligned}ϵt=Px∼Dt[f(x)=ht(x)]=N∑[f(x)=ht(x)]x∼Dt
基于化简后的Lexp[αtht(x)∣Dt]\mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right]Lexp[αtht(x)∣Dt],对权重参数αt\alpha_tαt求解偏导:
∂∂αtLexp[αtht(x)∣Dt]=−exp{−αt}⋅(1−ϵt)+exp{αt}⋅ϵt\frac{\partial}{\partial \alpha_t}\mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right] = -\exp\{-\alpha_t\} \cdot (1 - \epsilon_t) + \exp\{\alpha_t\} \cdot \epsilon_t∂αt∂Lexp[αtht(x)∣Dt]=−exp{−αt}⋅(1−ϵt)+exp{αt}⋅ϵt
令∂∂αtLexp[αtht(x)∣Dt]≜0\frac{\partial}{\partial \alpha_t}\mathcal L_{exp} \left[\alpha_th_t(x) \mid \mathcal D_t\right] \triangleq 0∂αt∂Lexp[αtht(x)∣Dt]≜0,求出αt\alpha_tαt的最优解:
αt=12ln(1−ϵtϵt)\alpha_t = \frac{1}{2} \ln \left(\frac{1 - \epsilon_t}{\epsilon_t}\right)αt=21ln(ϵt1−ϵt)
我们仅仅求解出ttt时刻的最优解是不够的,我们更希望新一轮产生的基学习器ht(x)h_t(x)ht(x)能够纠正前一轮预测模型Ht−1(x)\mathcal H_{t-1}(x)Ht−1(x)中的错误。
通过数学语言表达则是:新一轮产生的预测模型Ht(x)=Ht−1(x)+αtht\mathcal H_t(x) = \mathcal H_{t-1}(x) + \alpha_th_tHt(x)=Ht−1(x)+αtht能够使损失函数Lexp[Ht(x)∣D]\mathcal L_{exp}[\mathcal H_t(x) \mid \mathcal D]Lexp[Ht(x)∣D]达到最小。
需要注意的点:此时的预测模型Ht(x)\mathcal H_t(x)Ht(x)是从初始时刻开始到ttt时刻的‘加权模型’结果。它并非仅仅针对于ttt时刻采样数据集Dt\mathcal D_tDt,而是完整数据集D\mathcal DD.
Lexp[Ht(x)∣D]=Ex∼D[exp{−f(x)⋅Ht(x)}]=Ex∼D[exp{−f(x)⋅(Ht−1(x)+ht(x))}]=Ex∼D[exp{−f(x)⋅Ht−1(x)}⋅exp{−f(x)⋅ht(x)}]\begin{aligned} \mathcal L_{exp}[\mathcal H_t(x) \mid \mathcal D] & = \mathbb E_{x \sim \mathcal D} \left[\exp\{-f(x) \cdot \mathcal H_t(x)\}\right] \\ & = \mathbb E_{x \sim \mathcal D} \left[\exp\{-f(x) \cdot (\mathcal H_{t-1}(x) + h_t(x))\}\right] \\ & = \mathbb E_{x \sim \mathcal D} \left[\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\} \cdot \exp\{-f(x) \cdot h_t(x)\}\right] \end{aligned}Lexp[Ht(x)∣D]=Ex∼D[exp{−f(x)⋅Ht(x)}]=Ex∼D[exp{−f(x)⋅(Ht−1(x)+ht(x))}]=Ex∼D[exp{−f(x)⋅Ht−1(x)}⋅exp{−f(x)⋅ht(x)}]
观察项exp{−f(x)⋅ht(x)}\exp\{-f(x)\cdot h_t(x)\}exp{−f(x)⋅ht(x)},可以使用泰勒公式将其展开成如下形式:
由于‘真实函数’f(x)f(x)f(x),基学习器ht(x)h_t(x)ht(x)的值域均是{−1,+1}\{-1,+1\}{−1,+1},因而有f2(x)=ht2(x)=1f^2(x) = h_t^2(x) = 1f2(x)=ht2(x)=1
exp{−f(x)⋅ht(x)}=1−f(x)⋅ht(x)+f2(x)⋅ht2(x)2=1−f(x)⋅ht(x)+12\begin{aligned} \exp\{-f(x)\cdot h_t(x)\} & = 1 - f(x) \cdot h_t(x) + \frac{f^2(x) \cdot h_t^2(x)}{2} \\ & = 1 - f(x) \cdot h_t(x) + \frac{1}{2} \end{aligned}exp{−f(x)⋅ht(x)}=1−f(x)⋅ht(x)+2f2(x)⋅ht2(x)=1−f(x)⋅ht(x)+21
从而Lexp[Ht(x)∣D]\mathcal L_{exp}[\mathcal H_t(x) \mid \mathcal D]Lexp[Ht(x)∣D]可表示为如下形式:
Lexp[Ht(x)∣D]=Ex∼D[exp{−f(x)⋅Ht−1(x)}⋅(1−f(x)⋅ht(x)+12)]\mathcal L_{exp}[\mathcal H_t(x) \mid \mathcal D] = \mathbb E_{x \sim \mathcal D} \left[\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\} \cdot \left(1 - f(x) \cdot h_t(x) + \frac{1}{2}\right)\right]Lexp[Ht(x)∣D]=Ex∼D[exp{−f(x)⋅Ht−1(x)}⋅(1−f(x)⋅ht(x)+21)]
因而,基于纠错后ttt时刻最优基学习器可表示为:
将上面式子代入~其中常数1,121,\frac{1}{2}1,21均不影响最值的取值,消掉;将−f(x)⋅ht(x)-f(x)\cdot h_t(x)−f(x)⋅ht(x)中的负号提到前面,将argminht(x)\mathop{\arg\min}\limits_{h_t(x)}ht(x)argmin改成argmaxht(x)\mathop{\arg\max}\limits_{h_t(x)}ht(x)argmax这里添加一个技巧:将上述结果乘以一个常数:1Ex∼D[exp{−f(x)⋅Ht−1(x)}]\frac{1}{\mathbb E_{x \sim \mathcal D} \left[\exp \{-f(x) \cdot \mathcal H_{t-1}(x)\}\right]}Ex∼D[exp{−f(x)⋅Ht−1(x)}]1
首先,乘以一个常数并不影响上述公式最值的取值;其次,由于Ht−1(x)\mathcal H_{t-1}(x)Ht−1(x)是上一次迭代产生的预测模型,是已知项;因而Ex∼D[exp{−f(x)⋅Ht−1(x)}]\mathbb E_{x \sim \mathcal D} \left[\exp \{-f(x) \cdot \mathcal H_{t-1}(x)\}\right]Ex∼D[exp{−f(x)⋅Ht−1(x)}]是一个已知项,是一个常数。此时,第一项exp{−f(x)⋅Ht−1(x)}Ex∼D[exp{−f(x)⋅Ht−1(x)}]\begin{aligned}\frac{\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}}{\mathbb E_{x \sim \mathcal D} [\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}]}\end{aligned}Ex∼D[exp{−f(x)⋅Ht−1(x)}]exp{−f(x)⋅Ht−1(x)}整个就是一个常数项,并且分子是分母的一部分。由于期望自身就是积分,可以直接将这个常数项提出去:
h^t(x)=argmaxht(x){exp{−f(x)⋅Ht−1(x)}Ex∼D[exp{−f(x)⋅Ht−1(x)}]⋅Ex∼D[f(x)⋅ht(x)]}\hat h_t(x) = \mathop{\arg\max}\limits_{h_t(x)} \left\{\frac{\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}}{\mathbb E_{x \sim \mathcal D} [\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}]} \cdot \mathbb E_{x \sim \mathcal D} \left[f(x) \cdot h_t(x)\right]\right\}h^t(x)=ht(x)argmax{Ex∼D[exp{−f(x)⋅Ht−1(x)}]exp{−f(x)⋅Ht−1(x)}⋅Ex∼D[f(x)⋅ht(x)]}
核心思路:将这个常数项直接映射到数据基D\mathcal DD的特征空间中,相当于数据集合D\mathcal DD中的所有样本乘了一个常数项;并从这个集合中重新采样:
令Dt=exp{−f(x)⋅Ht−1(x)}Ex∼D[exp{−f(x)⋅Ht−1(x)}]⋅D\begin{aligned}\mathcal D_t = \frac{\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}}{\mathbb E_{x \sim \mathcal D} [\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}]} \cdot \mathcal D\end{aligned}Dt=Ex∼D[exp{−f(x)⋅Ht−1(x)}]exp{−f(x)⋅Ht−1(x)}⋅D,此时将采样分布从D\mathcal DD映射到了Dt\mathcal D_tDt又因为f(x),h(x)f(x),h(x)f(x),h(x)的值域均为{−1,+1}\{-1,+1\}{−1,+1},那么f(x)⋅h(x)f(x) \cdot h(x)f(x)⋅h(x)结果可表示为如下形式:
f(x)⋅h(x)={1h(x)=f(x)−1h(x)≠f(x)f(x)\cdot h(x) = \begin{cases} 1 \quad h(x) = f(x) \\ -1 \quad h(x) \neq f(x) \end{cases}f(x)⋅h(x)={1h(x)=f(x)−1h(x)=f(x)
使用一个式子表示,有:
I\mathbb II表示指示函数。
f(x)⋅h(x)=1−2⋅I[f(x)≠h(x)]f(x) \cdot h(x) = 1 - 2 \cdot \mathbb I [f(x) \neq h(x)]f(x)⋅h(x)=1−2⋅I[f(x)=h(x)]
将该式子带回上式,有:
下式中的常数(系数)1,21,21,2都可以消掉,将负号与argmax\arg\maxargmax合并成argmin\arg\minargmin.机器学习(西瓜书)P176.至此,可以发现,ttt时刻我们的最优基学习器h^t(x)\hat h_t(x)h^t(x)是可以直接从分布Dt\mathcal D_tDt中进行学习的,而不是仅被局限于原始数据集D\mathcal DD。继续观察上述最优化的项:
Ex∼Dt[I[f(x)≠h(x)]]=1N∑i=1NI[f(x(i))≠h(x(i))]\mathbb E_{x \sim \mathcal D_t} [\mathbb I[f(x) \neq h(x)]] = \frac{1}{N} \sum_{i=1}^N \mathbb I \left[f(x^{(i)}) \neq h(x^{(i)})\right]Ex∼Dt[I[f(x)=h(x)]]=N1i=1∑NI[f(x(i))=h(x(i))]
该一共NNN个项,并且每一项的值域为{0,1}\{0,1\}{0,1},那么这个期望结果必然是一个[0,1][0,1][0,1]之间的值:
当然,上述是极端情况。一般情况下,我们希望这个误差<0.5< 0.5<0.5,意味着第ttt次迭代对于样本的学习结果如果有一半以上没有学习正确,那就没有学习的必要了。
与此同时,Dt\mathcal D_tDt不是凭空生成的,也是经过一次又一次的迭代产生的。关于Dt+1\mathcal D_{t+1}Dt+1和Dt\mathcal D_tDt之间的关系表示如下:
将Ht(x)=Ht−1(x)+αtht(x)\mathcal H_t(x) = \mathcal H_{t-1}(x) + \alpha_th_t(x)Ht(x)=Ht−1(x)+αtht(x)代入。将上面的Dt\mathcal D_tDt与D\mathcal DD之间的关系代入。D=Dt⋅Ex∼D[exp{−f(x)⋅Ht−1(x)}]exp{−f(x)⋅Ht−1(x)}\begin{aligned}\mathcal D = \frac{\mathcal D_t \cdot \mathbb E_{x \sim \mathcal D}[\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}]}{\exp\{-f(x)\cdot \mathcal H_{t-1}(x)\}}\end{aligned}D=exp{−f(x)⋅Ht−1(x)}Dt⋅Ex∼D[exp{−f(x)⋅Ht−1(x)}]至此,关于加性模型的推导过程全部结束。可以观察一下基于加性模型下AdaBoost\text{AdaBoost}AdaBoost的算法流程:
基学习算法K\mathcal KK就是产生基学习器算法方式。它通过已知数据集D\mathcal DD和作用于数据集的分布参数Dt\mathcal D_tDt共同实现。其中配分项1Zt\frac{1}{\mathcal Z_t}Zt1是关于ttt时刻的项。并且1Zt=Ex∼D[exp{−f(x)⋅Ht−1(x)}]Ex∼D[exp{−f(x)⋅Ht(x)}]\frac{1}{\mathcal Z_t} = \frac{\mathbb E_{x \sim \mathcal D} [\exp\{-f(x) \cdot \mathcal H_{t-1}(x)\}]}{\mathbb E_{x \sim \mathcal D} [\exp\{-f(x) \cdot \mathcal H_t(x)\}]}Zt1=Ex∼D[exp{−f(x)⋅Ht(x)}]Ex∼D[exp{−f(x)⋅Ht−1(x)}]最终输出:
至此,AdaBoost\text{AdaBoost}AdaBoost的推导过程结束。下一节将介绍Gradient Boosting\text{Gradient Boosting}Gradient Boosting。
相关参考:
机器学习(周志华著)