10.1 k近邻学习(kNN)
给定测试样本,基于某种距离度量找出训练集中与其最靠近的k个训练样本,然后根据这k个邻居的信息进行预测
与前边的学习方法相比,kNN没有显式的训练过程,只有拿到测试样本以后才进行处理,我们将其称为懒惰学习(lazy learning),而哪些再训练阶段就对样本进行处理的方法叫做急切学习(eager learning)
给定测试样本 x x x,若其最近邻样本为 z z z,则最近邻分类器出错的概率是二者类别不同的概率,我们假设两个样本独立同分布
P ( e r r ) = 1 − ∑ c ∈ Y P ( c ∣ x ) P ( c ∣ z ) ≃ 1 − ∑ c ∈ Y P 2 ( c ∣ x ) ≤ 1 − P 2 ( c ∗ ∣ x ) = ( 1 + P ) ( 1 − P ) ≤ 2 × ( 1 − P ( c ∗ ∣ x ) ) \begin{aligned} P(err) &=1-\sum_{c\in Y}P(c|x)P(c|z) \\ &\simeq 1-\sum_{c\in Y}P^2(c|x) \\ &\leq 1-P^2(c^*|x) \\ &=(1+P)(1-P) \\ &\leq 2\times (1-P(c^*|x)) \end{aligned} P(err)=1−c∈Y∑P(c∣x)P(c∣z)≃1−c∈Y∑P2(c∣x)≤1−P2(c∗∣x)=(1+P)(1−P)≤2×(1−P(c∗∣x))
其中, P ( c ∗ ∣ x ) P(c^*|x) P(c∗∣x)表示贝叶斯最优分类器的结果。这表明最近邻分类器虽然简单,但是它泛化错误率不超过贝叶斯最优分类器的两倍
10.2 低维嵌入
我们首先介绍多维缩放算法(Multiple Dimensional Scaling,MDS)。
假定 m m m个样本再原始空间的距离矩阵为 D ∈ R m × m D\in \mathbb{R}^{m\times m} D∈Rm×m,其中的元素 d i s t i j dist_{ij} distij为样本 x i x_i xi到 x j x_j xj的距离。我们的目标是获得样本在 d ′ d' d′维空间的表示 Z ∈ R d ′ × m , d ′ ≤ d \mathbf{Z}\in\mathbb{R}^{d'\times m},d'\leq d Z∈Rd′×m,d′≤d,且任意两个样本在 d ′ d' d′维空间中的距离等于原始空间中的距离
我们令 B = Z T Z ∈ R m × m \mathbf{B}=\mathbf{Z}^T\mathbf{Z}\in \mathbb{R}^{m\times m} B=ZTZ∈Rm×m,为降维后的内积矩阵, b i j = z i T z j b_{ij}=z_i^Tz_j bij=ziTzj,则有
d i s t i j 2 = b i i + b j j − 2 b i j dist_{ij}^2=b_{ii}+b_{jj}-2b_{ij} distij2=bii+bjj−2bij
为了便于讨论,我们令降维后的样本 Z \mathbf{Z} Z被中心化,即 ∑ i = 1 m z i = 0 \sum_{i=1}^{m}z_i=0 ∑i=1mzi=0,矩阵 B \mathbf{B} B的行与列之和均为0,那么有
∑ i = 1 m d i s t i j 2 = t r ( B ) + m b j j ∑ j = 1 m d i s t i j 2 = t r ( B ) + m b i i ∑ i = 1 m ∑ j = 1 m d i s t i j 2 = 2 m t r ( B ) \sum_{i=1}^{m}dist_{ij}^2=tr{\mathbf{(B)}+mb_{jj}} \\ \sum_{j=1}^{m}dist_{ij}^2=tr{\mathbf{(B)}+mb_{ii}} \\ \sum_{i=1}^{m}\sum_{j=1}^{m}dist_{ij}^2=2m tr{\mathbf{(B)}} i=1∑mdistij2=tr(B)+mbjjj=1∑mdistij2=tr(B)+mbiii=1∑mj=1∑mdistij2=2mtr(B)
在此基础之上
d i s t i ⋅ 2 = 1 m ∑ j = 1 m d i s t i j 2 d i s t ⋅ j 2 = 1 m ∑ i = 1 m d i s t i j 2 d i s t ⋅ ⋅ 2 = 1 m 2 d i s t i j 2 dist_{i·}^2=\frac{1}{m}\sum_{j=1}^{m}dist_{ij}^2\\ dist_{·j}^2=\frac{1}{m}\sum_{i=1}^{m}dist_{ij}^2 \\ dist_{··}^2=\frac{1}{m^2}dist_{ij}^2 disti⋅2=m1j=1∑mdistij2dist<