集成算法(chapter 7 - Hands on machine learning with scikit learn and tensorflow)
Voting classifier
多种分类器分别训练,然后分别对输入(新数据)预测/分类,各个分类器的结果视为投票,投出最终结果:
训练:
投票:
为什么三个臭皮匠顶一个诸葛亮。通过大数定律直观地解释:
一个硬币P(H)=0.51。大数定律保证抛硬币很多次之后,平均得到的正面频数接近\(0.51 \times N\),并且N越大,越接近。那么换个角度,N表示同时掷硬币的人数,即为这边的N个臭皮匠,他们的结果合到一起就得到的是接近真实结果的值。
进一步根据中心极限定理,即二项分布以正态分布为其极限分布定律,可以计算“N次抛硬币后,header占大多数的概率”
例如P(H)=0.51,N=1000,则\(\Pr(\text{Header 占大多数}) = 1-\Phi (\frac{n/2 - np}{\sqrt{np(1-p)}})=\Phi(0.63)=0.74\),当N=10000,\(Pr=\Phi(2)=0.98\)
Bagging and Pasting
跟投票的思路不同,Bagging(boost aggregating)的思路是同一算法训练多个模型,每个模型训练时只使用部分数据。预测时,每个模型分别给出自己的预测结果,再将这些结果聚合起来。
Out Of Bag
因为每个模型训练时随机选择每个训练sample数据,那么,对于某个sample而言,有可能被选中0次或多次。如果一个sample没有被选中,那么它很自然地可以被用做交叉验证。
某个sample至少被一个模型训练用到的概率,\(\Pr(\text{sample被选中})=1-\left( 1- \frac{1}{N}\right)^k\)
\(k=N\), \(\lim_{N\to\infty}1-\left(1-\frac{1}{N}\right)^N=1-e^{-1} =0.63\)
parallel training pattern
bagging算法需要训练多个模型,每个模型的训练过程相同,只是算法使用的数据不同。联想到并行训练的问题,两种思路:
- 如果训练样本数比较小,每个模型能够承受所有数据,那么使用上面的模式。
- 如果训练样本很大,需要分区到多个cpu/节点上,那么每个节点只消费部分训练样本,但是每个节点可以同时训练多个模型,最终再把各个模型的半成品结合到一起形成完整的模型。
随机森林
随机森林一般采用bagging算法训练模型。
rnd_clf = RandomForestClassifier(n_estimators=500, max_leaf_nodes=16, n_jobs=-1)
bag_clf = BaggingClassifier(
DecisionTreeClassifier(splitter="random", max_leaf_nodes=16),
n_estimators=500, max_samples=1.0, bootstrap=True, n_jobs=-1
)
Feature Importance
Lastly, if you look at a single Decision Tree, important features are likely to appear closer to the root of the tree, while unimportant features will often appear closer to the leaves (or not at all). It is therefore possible to get an estimate of a feature’s importance by computing the average depth at which it appears across all trees in the forest.
Boosting
定义:any Ensemble method that can combine several weak learners into a strong learner. The general idea of most boosting methods is to train predictors sequentially, each trying to correct its predecessor.
AdaBoosting
如果各一个样本被predecessor分类器误分类了,那么下一个分类器将会更重视这个样本(boost/提升这个样本)。
所以在顺序训练模型时,每个样本的重要性在变化:
Gradient Boosting
Gradient Boosting也是通过不断增加predictor来修正之前的predictor。不同于adaboost的地方是,gradient boosting调整每个样本的权重,后面的predictor直接去拟合前面的predictor的残差(residual error).
Stacking (stacked generalisation)
多层训练模型的雏形。
集成算法(chapter 7 - Hands on machine learning with scikit learn and tensorflow)的更多相关文章
- How do I learn machine learning?
https://www.quora.com/How-do-I-learn-machine-learning-1?redirected_qid=6578644 How Can I Learn X? ...
- [GPU] Machine Learning on C++
一.MPI为何物? 初步了解:MPI集群环境搭建 二.重新认识Spark 链接:https://www.zhihu.com/question/48743915/answer/115738668 马铁大 ...
- [翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed Systems"
[翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed ...
- Machine Learning for Developers
Machine Learning for Developers Most developers these days have heard of machine learning, but when ...
- Azure Machine Learning
About me In my spare time, I love learning new technologies and going to hackathons. Our hackathon p ...
- 壁虎书2 End-to-End Machine Learning Project
the main steps: 1. look at the big picture 2. get the data 3. discover and visualize the data to gai ...
- A Gentle Guide to Machine Learning
A Gentle Guide to Machine Learning Machine Learning is a subfield within Artificial Intelligence tha ...
- Bayesian machine learning
from: http://www.metacademy.org/roadmaps/rgrosse/bayesian_machine_learning Created by: Roger Grosse( ...
- [Machine Learning] 机器学习常见算法分类汇总
声明:本篇博文根据http://www.ctocio.com/hotnews/15919.html整理,原作者张萌,尊重原创. 机器学习无疑是当前数据分析领域的一个热点内容.很多人在平时的工作中都或多 ...
随机推荐
- Python配置工具类ConfigParser使用
ConfigParser模块定义了类ConfigParser,用于实现配置文件解释器.该模块ConfigParser在Python3中,已更名为configparser. 一,函数介绍 1.读取配置文 ...
- jx9脚本引擎BUG修复
BUG1: rc = WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pOutput, (DWORD)nOutputLen, 0, 0); 修 ...
- Servlet API
Servlet API的查询网址:通过Tomcat的官网链接找到 可见,Servlet API有4个packages javax.servlet // 包含定义Servlet和Servlet容器之间契 ...
- java多线程知识点
下面是我学习多线程记录的知识点,并没详细讲解每个知识点,只是将重要的知识点记录下来,有时间可以看看,如果有不对的地方,欢迎大家指出,谢谢! 1.多线程的状态和创建方式: 线程的状态: ...
- dubbo学习(zz)
dubbo学习 博客分类: 开源软件 Dubbo是阿里巴巴SOA服务化治理方案的核心框架,每天为2,000+个服务提供3,000,000,000+次访问量支持,并被广泛应用于阿里巴巴集团的各成员站 ...
- 2017/2/8 hibernate + oracle 实现id的自增 同时 hibernate项目跑起来 会自己增加字段的原因 oracle触发器的使用
hibernate + oracle 实现id的自增 1.在oracle中先创建一个序列 : 序列语法 如下 create sequence (序列名称)seq_student_id minva ...
- 2017/2/5:oracle数据库的三大文件
oracle的三大文件: 一:控制文件:控制文件是一个小型的二进制文件,可以记录数据库的物理结构.包括: * 数据库名称 * 数据文件和日志文件的名称和位置 * 数据库创建的时 ...
- 【Web】网页清除浮动的方法
网页中,经常用浮动的div来布局,但是会出现父元素因为子元素浮动引起内部高度为0的问题,为了解决这个问题,我们需要清除浮动,下面介绍4中清除浮动的方法. 在CSS中,clear属性用户清除浮动,语法: ...
- [cmd]如何设置 Windows 默认命令行窗口大小和缓冲区大小
Windows 命令行 cmd 窗口系统默认的大小(80*40)对于现在的屏幕配置已经跟不上时代了,我们总是要把它改大些,而且缓冲区大小也想改得大大的.单纯的为当前的 Windows 命令行窗口修改显 ...
- keras框架的CNN手写数字识别MNIST
参考:林大贵.TensorFlow+Keras深度学习人工智能实践应用[M].北京:清华大学出版社,2018. 首先在命令行中写入 activate tensorflow和jupyter notebo ...