Ensemble Learning and Random Forest

1. Voting Classifiers

  • 分类
    • hard voting: 选择投票最多的类别
    • soft voting: 选择概率和最大的类别,通常会比 hard voting 效果好一些。
  • many weak leaners -> strong learner
  • 性能有限的原因
    • 各个classifier之间不够 independent, 预测的 错误结果 之间通常有一定的关联性 => classifiers 是在相同的数据集上 训练得到的
  • 解决方法
    • train them using very different algorithms. => 产生的错误类型不同

2. Bagging and Pasting

2.1 Bagging ( B ootstrap ~ agg regat ing )
  • 算法流程
    • Training set consists of m training examples drawn randomly with replacement from the original training set of n items. (The training set is called a bootstrap replicate)
    • Train a classifier with the training set.
    • Repeat the procedure L times and get L classifiers.
    • Test: hard voting
  • 应用场景
    • 不太稳定的分类器:如决策树(SVM相对来说比较稳定)。
  • evaluate
    • 用每个 predictor 的 out-of-bag (oob,即未被采样的样本) evaluate,因为 Predictor 在 training 的过程中不会见到 oob 样本。
    • ensemble 的性能可以通过 average 每个 Predictor 的 oob evaluation 得到。
2.2 Pasting

与Bagging不同的是,采样过程是 without replacement 的。

【注意】
- bagging 和 pasting 都允许同一训练样本参与多个 predictors 的训练,但只有 bagging 才允许同一训练样本在同一 predictor 的训练中被多次采样。
- 每个独立的 predictor 的 bias 都会比在整个训练集上train得的 predictor 高,但是 aggregation 操作能够同时降低 bias 和 variance. 即,最终得到的 ensembel 具有相似的 bias,但是 variance 更小。
- 虽然训练时间更长,但是可以并行训练

3. Random Patches and Random Subspaces

  • random patches method
    • sampling both training instances and features
  • random subspaces method
    • keeping all training instances but sampling features

4. Random Forests

个人理解:由很多棵决策树构成,最后通过voting等手段进行ensemble。由于决策树的构建具有很大的随机性,所以random forest 能够有效降低决策树算法的 variance,从而取得更好的效果。

4.1 Extra-Trees
  • Extremely randomized trees ensemble (缩写为 Extra-trees)
    • 每棵树都是由 random 选出的不同的 subspaces (features) 构建而成的。
    • also using random thresholds for each feature rather than searching for the best possible thresholds
  • 特点:
    • trade more bias for a lower raviance
  • 与 regular Random Forests 相比:
    • 训练速度更快 (一般的随机森林算法需要通过寻优确定threshold
    • 具体效果需要通过 cross-validation 确定
4.2 Feature Importance

一般来说,就单个决策树,越重要的特征距离根节点越近,因此,特征的重要度可能通过随机森林中各决策树中各特征的平均深度来衡量。在理解 feature importance 的基础上,可以进一步展开fature selection 操作。

5. Boosting

  • Originally called hypothesis boosting.
  • General idea: train predictors sequentially, each trying to correct its predecessor.
  • 代表性 booting 算法
    • AdaBoost (Adaptive Boosting)
    • Gradient Boosting
5.1 AdaBoost
  • Motivation
    • finding many rough rules of thumb can be a lot easier than finding a single, highly accurate prediction rule.
    • Combine these weak rules into a single prediction rule that will be much more accurate than any one of the weak rules.
  • 核心思想
    • 序列学习的分类器,给错分的样本更大的采样权重
    • The final classifier is constructed by a weighted vote of the individual classifiers.
  • 缺陷
    • 无法并行计算或只能部分并行计算
  • 算法要点
    • 每个样本权重初始化 w(i)=1m w ( i ) = 1 m
    • sampling & training. 训得当前predictor,计算加权错误率 r1 r 1 .
      • j j 个predictor的加权错误率rj
        rj=mi=1,ŷ (i)jy(i)w(i)mi=1w(i) r j = ∑ i = 1 , y ^ j ( i ) ≠ y ( i ) m w ( i ) ∑ i = 1 m w ( i )
      • j j 个predictor最终投票的权重αj为:
        αj=ηlog1rjrj α j = η log ⁡ 1 − r j r j
    • 更新采样权重:
      w(i){w(i)w(i)exp(αj) if ŷ (i)j=y(i) if ŷ (i)jy(i)(1) (1) w ( i ) ← { w ( i )   i f   y ^ j ( i ) = y ( i ) w ( i ) exp ⁡ ( α j )   i f   y ^ j ( i ) ≠ y ( i )
    • 权重归一化
    • 停止条件
      • pedictors 的数目达到上限
      • A perfect predictor is found.
    • 做预测
      • 利用所有的predictor进行预测,然后再利用 αj α j 对结果进行加权。
  • 后续发展:SAMME
    • a multiclass version of AdaBoost
5.2 Gradient Boosting
  • 核心思想
    • working sequentially.
    • fit the new predictor to the residual errors made by the previous predictor.
    • 更多面向 regression task
  • 典型应用:Gradient Tree Boosting / Gradient Boosted Regression Tree (GBRT)
    • base predictor: Regression Tree
    • 做预测:把不同predicotr的预测结果加起来即可
    • regularization: shrinkage
      • 通过调节learning_rate实现
      • learning_rate: scales the contribution of each tree
      • learning_rate越小,ensemble需要越多的回归树来拟合训练集,regularization效果越明显。
  • 如何确定最优的 ensemble 包含的 tree 的数目?
    • early stopping: 监测ensemble中每加入 n n trees 后 validate ensemble 的预测准确度:
  • Stochastic Gradient Boosting
    • 每次利用在原始训练集上进行采样得到的子训练集训练
    • trade a higher bias for a lower variance
    • speed up training considerably

6. Stacking (Stacked Generalization, 层叠/堆栈泛化)

  • 核心思想
    • 训练一个模型(blender / meta learner)来生成最终对多个predictors的整合,而不是通过直接利用投票/加权和的方式来产生最终预测结果。
  • to train a blender
    • 原始训练集 T 拆分为两个子集 T1 T 1 T2 T 2
      • T1 T 1 : 用于训练构成 ensembel 的多个 predictors
      • T2 T 2 : the hold-out set
    • 利用 predictors 进行预测,得到多个 predictions
    • 再利用 T2 T 2 训练 blender
    • blender 输入特征的维度即为 predictors 的数目
  • 可以同时训练多个 blenders
    • 例如训练服昂发分别为 Linear Regression, Radom Forest Regression and so forth.
    • 从而形成 a layer of blenders
    • 此时,需要把训练集分为 3 部分

另外,有一篇文献对 ensemble learning 总结的特别好,见:集成学习总结

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值