[关闭]
@lyc102 2017-04-10T00:49:40.000000Z 字数 5930 阅读 3357

机器学习(周志华)第二章:模型评估与选择

machine_learning


经验误差与过拟合

预测输出与真实输出之间的差异称为误差(error)

我们希望得到泛化误差小的学习器,实际能做的是努力使经验误差最小化。为了在新样本上表现好,应该从训练样本中学习出所有潜在样本的“普遍规律”。

过拟合是机器学习面临的关键障碍,是无法彻底避免的,所能做的只是“缓解”。深层次的原因:问题本身是NP的,算法是P的。相信“NP P",则过拟合就不可避免。

模型选择(model selection)问题。理想方案:最小化泛化误差。但泛化误差无法直接获取。最小化训练误差又会导致过度拟合。

评估方法

用“测试误差”,即模型在测试集上的误差,作为泛化误差的近似。测试集应该尽可能与训练集互斥。

对数据集 做适当处理,从中产生训练集 和测试集

留出法 (hold-out)

.

训练和测试集的划分要尽可能保持数据分布的一致性,避免因数据划分引入额外的偏差。一种保留类别比例的采样:stratified sampling.

单次使用留出法得到的估计结果不够稳定可靠。一般采用若干次随机划分、重复实验取平均值。

常见做法:大约 的样本用于训练,剩余样本用于测试。

交叉验证法(cross validation)

做一个个大小相似的partition, . 留下一个做测试集,其他作为训练集,从而得到 次训练和测试。划分本身还要随机重复 次,最终的评估结果是这 折交叉验证结果的均值。

特殊例子:, 称为留一法(LOO). 当 很大时工作量太大。

自助法 (bootstrapping)

自助采样(bootstrap sampling):sampling with replacement.

有一部分样本会重复出现,有一部分不会出现。样本在 次采样中始终不被采到的概率是:


所以大约有 强的样本不会在采样集中出现。采样数据集作为训练集,剩下的作为测试集。

自助法在数据集较小、难以有效划分时有用。但自助法改变了初始数据集的分布,会引入估计偏差。

调参与最终模型

参数空间太大,调参的工作量很大。在不少应用中,参数调得好不好往往对最终模型性能有关键性影响。

如果误差函数对参数是光滑的,可以用优化算法寻找最优参数

模型评估与选择中用于评估测试的数据集称为 validation set,和测试集不同,属于训练数据中的一部分。

性能度量(performance measure)

回归任务最常用的是“均方误差”(mean squared error)


更一般地,对于数据分布 和 p.d.f. ,

错误率与精度

对于数据分布 和 p.d.f. , 错误率

精度是

查准率、查全率与F1

以信息检索为例:

查准率和查全率是一对矛盾的度量。P-R曲线。若一个学习器的曲线被另一个完全包住,则后者更优,如果交叉,则难以断言。比较合理的依据是P-R曲线所包含的面积,越大越好。

平衡点(Break-Event Point)是两者相等的点。可以根据平衡点的大小来度量。

F1是基于查准率和查全率的调和平均:

F1度量的一般形式:

多次训练/测试的结果,可以先算查准率和查全率,再对两者做平均,或者先对数据做平均,再算查准率和查全率。

ROC 与 AUC

代价敏感错误率与代价曲线

比较检验

机器学习中性能比较比想象的要复杂。原因有三:
1. 希望比较泛化性能,但获得的度量是测试集上的,两者有差别;
2. 测试集上的性能和测试集的选取有关;
3. 算法的随机性。

统计假设检验(hypothesis test). 若在测试集上学习器A比B好,则A的泛化性能是否在统计意义上优于B,以及这个结论的把握有多大。

假设检验

假设:

把一个确定性的不等式 转化为以一定概率成立的 statement, e.g. or .

考虑分类问题。样本总数为 ,则误分类个数的上届是 . Let be the random variable representing the number of correct classification examples. Then . Given a small number , we consider the inequality

or equivalently the tail bound
Here is fixed, and is given. Only is a variable. We use to emphasize the dependence of . When , e.g. , then obviously the inequality holds. As we increase , the tail (for a mixed point ) will go to and violates the inequality. Mathematically and is an increasing function of . Thus given an , we have a maximum , i.e., , so that

draw a picture here.

Then we compare the test error with ,

Student t-distribution and t-test
From Wiki. Let be i.i.d random variables with mean and variance . Let

be the sample mean and let
be the sample variance. Then the random variable
and the random variable by replacing the true variance by the sampled variance
follows t-distribution of degree . The true mean can be further replaced by the sampled mean . Then we can have a t-distribution random variable without knowning the true mean and true variance.

The t-distribution is symmetric and bell-shaped, like the normal distribution, but has heavier tails, meaning that it is more prone to producing values that fall far from its mean. Student's t-distribution with zero mean and degree has the probability density function given by

As , it decays to zero with a polynomial rate slower than the exponential one in the normal distribution. So it has heavier tails.

figure here

应用到交叉检验。假设有k个测试错误率, we can form a random variable

where is the sampled mean and is the sampled variance of .

Given an , we find an interval , 称为置信区间, such that

如果 sampled mean 的差值在这个区间,即可认为泛化误差错误率为 , 置信度为 .

交叉验证 t 检验

McNemar 检验

Friedman 检验与 Nemenyi 后续检验

偏差与方差

Bias-variance decomposition

and thus are random variables. So is . and are numbers.

The bias-variance decomposition can be easily proved by using the orthogonality and .

bias-variance dilemma. 偏差与方差是有冲突的。初期是偏差主导,后期是方差主导。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注