LFTP Ch2监督学习导论
给定一系列观测数据\((x_i,y_i)\),需要推广到未观测数据的位置上去
the main goal of supervised learning is to predict a new y ∈ Y given a new previously unseen x ∈ X. The unobserved data are usually referred to as the “testing data.”
其中自变量所在的空间\(\mathcal X\)往往具有可以利用的特定结构,我们不是将\(X\)映射到一个d维的向量空间,就是隐式使用样本之间的相似度/不相似度。
either by building an explicit mapping from X to a vector space (such as Rd) or implicitly by using a notion of pairwise dissimilarity or similarity between pairs of inputs.
最经典的因变量是分类问题的离散取值,回归问题的实数取值。当然,实际上输出可以是任意具有结构的特征,包括一张的图片(矩阵),一个图,一个文本序列(GPT),这就需要合理安排损失函数。
The most classical examples are binary labels Y = {0, 1} or Y = {−1, 1}, multicategory classification problems with Y = {1, . . . , k}, and classical regression with real responses/outputs Y = R.
然而,监督学习往往具有以下的几个困难点
1.噪声:由于因变量和自变量之间并不是支配性的地位。对于离散变量问题,y可能只受X的概率影响,对应的是一个与x有关的分布;对于连续变量的回归问题,\(y=f(x)+\varepsilon\),其中\(\varepsilon\)是一个均值为0的随机变量。而且事实上确实存在未被观测到的隐变量,
2预测对应的函数可能非常复杂
3观测到的变量只有有限个
4输入变量空间可能很大
5训练分布和测试分布可能差别很大
6对于什么是“好”的表现没有明确的规则
Decision Theory
fixed (testing) distribution p(x,y) on X × Y, with marginal distribution p(x) on X. Note that we make no assumptions at this point on the input space X.
此处还可以讲的更形式一点,只不过就不管了。
We ignore measurability issues on purpose.
损失函数的选取
损失函数实际上就是要找一个ℓ
二分类问题\(ℓ(y, z) = 1_{y\neq z} (0–1 loss)\)
多分类问题\(ℓ(y, z) = 1_{y\neq z} (0–1 loss)\)
回归问题:\(ℓ(y, z) = (y-z)^2\)
对于一个预测的函数, f : X → Y,一个损失函数ℓ : Y × Y → R, 和一个概率分布p on X × Y, f的期望风险被定义为
\(f(x)=argmax_{k\in K} \mathbb P(Y=k|X=x)\)
对于回归问题:
\(f(x)=\mathbb E (Y|X=x)\)
Exercise 2.1 Consider binary classification with Y = {−1, 1} with the loss function ℓ(−1,−1) = ℓ(1, 1) = 0 and ℓ(−1, 1) = c− > 0 (cost of a false positive), ℓ(1,−1) = c+ > 0 (cost of a false negative). Compute a Bayes predictor at x as a function of E[y|x].
\(f(x_0) = l(a,1)P(y=1|x=x_0)+l(a,-1)P(y=-1|x=x_0)\)
令\(p(x_0) = P(y=1|x=x_0)\)
a=1 \(c_{+}(1-p)<c_{-}p,1/p<c_-/c_++1)\)
a=-1\(c_{+}(1-p)>c_{-}p,1/p<c_-/c_++1)\)
Exercise 2.2 We consider a learning problem on \(X × Y\), with \(Y = \mathbb R\) and the absolute loss defined as \(ℓ(y, z) = |y − z|\). Compute a Bayes predictor \(f^∗ : X \rightarrow \mathbb R\).
因此
Exercise 2.5 (Inverting predictions) Consider the binary classification problem with Y = {−1, 1} and the 0–1 loss. Relate the risk of a prediction f to that of its opposite −f. Exercise 2.6 (“Chance” predictions) Consider binary classification problems with the 0–1 loss. What is the risk of a random prediction rule where we predict the two classes with equal probabilities independent of input x? Address the same question with multiple categories. Exercise 2.7 () Consider a random prediction rule where we predict from the proba- bility distribution of y given x. When is this achieving the Bayes risk?
k-邻域算法
Exercise 2.8 How would the curve move when n increases (assuming the same balance between classes)?
随着训练样本的增加,test先减后增
随机抽一份训练集 \(D_n(p)\),用算法 \(A\) 训练出模型 \(A(D_n(p))\)。那么这个模型的真实风险 \(R_p(A(D_n(p)))\) 距离最优 Bayes risk \(R_p^*\) 不超过 \(\varepsilon\) 的概率至少是 \(1-\delta\)。
学习理论想证明类似:
这时就可以说:
No Free Lunch
二分类,\(Y=\{0,1\}\),0–1 loss:
\(R_p^*\) 是 Bayes risk,即如果你完全知道真实分布 \(p\),理论上能达到的最小错误率:
证明的构造大概是这样。
因为 \(X\) 无限,所以可以从 \(X\) 中挑出 \(k\) 个不同点:
因为后面构造的分布满足
原文:
原文:
因为这个构造下
we want to maximize S(r) with respect to r∈{0,1}k.
因为证明目标是找一个坏分布 \(p\)。而每一个 \(r\) 都对应一个分布 \(p_r\)。所以只要能找到某个 \(r\),使得
也就是:
这里 \(q\) 是 \(r\) 上的均匀分布,也就是让
如果随机选 \(r\) 时平均表现已经很坏,那么至少存在一个具体的 \(r\) 也很坏。
原文:
对训练集 \(D_n\) 再取期望,就是:
又因为在构造中
具体是:
并且这些对象彼此独立,除了标签由
Dn(p)={(x1,rx1),…,(xn,rxn)}.
意思是算法实际看见的是这些信息:
问题是,算法只有 \(n\) 个训练样本。当 \(k\gg n\) 时,训练集只覆盖了这 \(k\) 个点中的很小一部分。测试点 \(X\) 没出现在训练集中的概率是
对于没见过的点,如果标签向量 \(r\) 是任意的,算法没有任何信息判断 \(r_X\) 是 0 还是 1。于是错误概率至少接近