Random Forest And Extra Trees
随机森林
我们对使用决策树随机取样的集成学习有个形象的名字–随机森林。
scikit-learn 中封装的随机森林,在决策树的节点划分上,在随机的特征子集上寻找最优划分特征。
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
X, y = datasets.make_moons(n_samples=500, noise=0.3, random_state=666)
plt.scatter(X[y==0, 0], X[y==0, 1])
plt.scatter(X[y==1, 0], X[y==1, 1])
plt.show()

from sklearn.ensemble import RandomForestClassifier
rf_clf = RandomForestClassifier(n_estimators=500, random_state=666, oob_score=True)
rf_clf.fit(X, y)
RandomForestClassifier(bootstrap=True, class_weight=None, criterion=’gini’,
max_depth=None, max_features=’auto’, max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimat 大专栏 Random Forest And Extra Treesors=500, n_jobs=1,
oob_score=True, random_state=666, verbose=0, warm_start=False)
rf_clf.oob_score_
0.892
自定义决策树某些参数
rf_clf2 = RandomForestClassifier(n_estimators=500, max_leaf_nodes=16
, random_state=666, oob_score=True)
rf_clf2.fit(X, y)
rf_clf2.oob_score_
0.906
Extra-Trees
在决策树的节点划分上,使用随机的特征和随机的阈值。
随机性更加极端。
提供了额外的随机性,一直过拟合,但增大了 bias 。
更快的训练速度。
from sklearn.ensemble import ExtraTreesClassifier
et_clf = ExtraTreesClassifier(n_estimators=500, bootstrap=True
, random_state=666, oob_score=True)
et_clf.fit(X, y)
ExtraTreesClassifier(bootstrap=True, class_weight=None, criterion=’gini’,
max_depth=None, max_features=’auto’, max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=500, n_jobs=1,
oob_score=True, random_state=666, verbose=0, warm_start=False)
et_clf.oob_score_
0.892
集成学习解决回归问题
from sklearn.ensemble import BaggingRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.ensemble import ExtraTreesRegressor
Random Forest And Extra Trees的更多相关文章
- sklearn_随机森林random forest原理_乳腺癌分类器建模(推荐AAA)
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...
- Plotting trees from Random Forest models with ggraph
Today, I want to show how I use Thomas Lin Pederson's awesome ggraph package to plot decision trees ...
- 机器学习算法 --- Pruning (decision trees) & Random Forest Algorithm
一.Table for Content 在之前的文章中我们介绍了Decision Trees Agorithms,然而这个学习算法有一个很大的弊端,就是很容易出现Overfitting,为了解决此问题 ...
- 3. 集成学习(Ensemble Learning)随机森林(Random Forest)
1. 集成学习(Ensemble Learning)原理 2. 集成学习(Ensemble Learning)Bagging 3. 集成学习(Ensemble Learning)随机森林(Random ...
- 随机森林random forest及python实现
引言想通过随机森林来获取数据的主要特征 1.理论根据个体学习器的生成方式,目前的集成学习方法大致可分为两大类,即个体学习器之间存在强依赖关系,必须串行生成的序列化方法,以及个体学习器间不存在强依赖关系 ...
- [Machine Learning & Algorithm] 随机森林(Random Forest)
1 什么是随机森林? 作为新兴起的.高度灵活的一种机器学习算法,随机森林(Random Forest,简称RF)拥有广泛的应用前景,从市场营销到医疗保健保险,既可以用来做市场营销模拟的建模,统计客户来 ...
- paper 85:机器统计学习方法——CART, Bagging, Random Forest, Boosting
本文从统计学角度讲解了CART(Classification And Regression Tree), Bagging(bootstrap aggregation), Random Forest B ...
- 多分类问题中,实现不同分类区域颜色填充的MATLAB代码(demo:Random Forest)
之前建立了一个SVM-based Ordinal regression模型,一种特殊的多分类模型,就想通过可视化的方式展示模型分类的效果,对各个分类区域用不同颜色表示.可是,也看了很多代码,但基本都是 ...
- Random Forest Classification of Mushrooms
There is a plethora of classification algorithms available to people who have a bit of coding experi ...
随机推荐
- Spring和MyBatis的集成
Spring和MyBatis的整合 1. Spring和各个框架的整合 Spring目前是JavaWeb开发中最终的框架,提供一站式服务,可以其他各个框架整合集成 Spring整合方案 1.1. ...
- list交集、差集、并集、去重并集
// 交集 List<String> intersection = list1.stream().filter(item -> list2.contains(item)).colle ...
- E - Rebuild UVALive - 7187 (二次函数极值问题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5531 Problem Description Archaeologists find ruins of ...
- Codeforces1303F Number of Components
Description link 题意:给一个全\(0\)矩阵,每次支持一个修改,修改不还原(这要是还原了不就成\(A\)题了) 然后询问每一次修改完了当前矩阵的连通块个数 每一个修改的值单调不降 修 ...
- oBike退出新加坡、ofo取消免押金服务,全球共享单车都怎么了?
浪潮退去后,才知道谁在裸泳.这句已经被说烂的"至理名言",往往被用在一波接一波的互联网热潮中.团购.O2O.共享单车.共享打车.无人货柜--几乎每一波热潮在退去后会暴露出存在的问题 ...
- 爬虫笔记(二)——浏览器的模拟(Headers属性)
有的时候,我们无法爬取一些网页,会出现403错误,因为这些网页为了防止别人恶意采集其信息所以进行了一些反爬虫的设置.那么如果我们向爬取这些网页的信息,应该怎么办呢? 可以设置一些Headers信息,模 ...
- Point Estimation
Point Estimation \(\bullet\)What is point estimation? Example: \(\bullet\) Bevan, Kullberg, and Rice ...
- 快手为什么要全资收购Acfun?
近日据媒体报道,快手已完成对「Acfun」以下简称A站的全资收购.未来A站仍将保持独立品牌和独立运营以及原有团队的独立发展.近年来,A站可谓命途多舛.相比隔壁B站风风光光顺利上市且成为真正的二次元大本 ...
- layui表格自动对齐
正常情况table应该是这样展示的 但是却展示成了这样 格子没对齐,找了半天原因发现是在table.render中的cols参数多了一个"," 不细心一点真看不出来 正常结构应是 ...
- 对“深入理解 Java 内存模型(六)——final”的学习
转载自https://www.infoq.cn/article/java-memory-model-6/ 与前面介绍的锁和 volatile 相比较,对 final 域的读和写更像是普通的变量访问.对 ...