随机森林

我们对使用决策树随机取样的集成学习有个形象的名字–随机森林。

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的更多相关文章

  1. sklearn_随机森林random forest原理_乳腺癌分类器建模(推荐AAA)

     sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...

  2. 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 ...

  3. 机器学习算法 --- Pruning (decision trees) & Random Forest Algorithm

    一.Table for Content 在之前的文章中我们介绍了Decision Trees Agorithms,然而这个学习算法有一个很大的弊端,就是很容易出现Overfitting,为了解决此问题 ...

  4. 3. 集成学习(Ensemble Learning)随机森林(Random Forest)

    1. 集成学习(Ensemble Learning)原理 2. 集成学习(Ensemble Learning)Bagging 3. 集成学习(Ensemble Learning)随机森林(Random ...

  5. 随机森林random forest及python实现

    引言想通过随机森林来获取数据的主要特征 1.理论根据个体学习器的生成方式,目前的集成学习方法大致可分为两大类,即个体学习器之间存在强依赖关系,必须串行生成的序列化方法,以及个体学习器间不存在强依赖关系 ...

  6. [Machine Learning & Algorithm] 随机森林(Random Forest)

    1 什么是随机森林? 作为新兴起的.高度灵活的一种机器学习算法,随机森林(Random Forest,简称RF)拥有广泛的应用前景,从市场营销到医疗保健保险,既可以用来做市场营销模拟的建模,统计客户来 ...

  7. paper 85:机器统计学习方法——CART, Bagging, Random Forest, Boosting

    本文从统计学角度讲解了CART(Classification And Regression Tree), Bagging(bootstrap aggregation), Random Forest B ...

  8. 多分类问题中,实现不同分类区域颜色填充的MATLAB代码(demo:Random Forest)

    之前建立了一个SVM-based Ordinal regression模型,一种特殊的多分类模型,就想通过可视化的方式展示模型分类的效果,对各个分类区域用不同颜色表示.可是,也看了很多代码,但基本都是 ...

  9. Random Forest Classification of Mushrooms

    There is a plethora of classification algorithms available to people who have a bit of coding experi ...

随机推荐

  1. Laravel常见问题总结

    1.Whoops, looks like something went wrong. 一般报这个问题是由于复制框架文件时没有把相应的env (隐藏文件) 复制 导致新复制的框架没有配置选项 解决方法: ...

  2. 三、NOSQL之Memcached缓存服务实战精讲第二部

    1.Memcached服务安装 Memcached的安装比较简单,很多平台都是支持Memcached,常见的有:Linux .Windows 服务端端:                cd /home ...

  3. 安装chrome并设置默认主页

    chrome 版本 https://support.google.com/chrome/a/answer/187948?hl=en&ref_topic=2936229

  4. Spring Boot Session 超时时间

    springboot session https://www.jianshu.com/p/523572937db8 springboot2以上版本设置session超时时间 https://blog. ...

  5. Haploid inheritance|Hardy-Weinberg proportions|

    I.2 Haploid inheritance 单倍体也有短暂的二倍体时期: Meiosis:减数分裂 依据图示信息,同时基因型A的频率是p,基因型a的频率是(1-p): 建立Hardy-Weinbe ...

  6. Python运维中常用的_脚本

    前言 file是一个类,使用file('file_name', 'r+')这种方式打开文件,返回一个file对象,以写模式打开文件不存在则会被创建.但是更推荐使用内置函数open()来打开一个文件. ...

  7. 2019-2020-1 20199324《Linux内核原理与分析》第三周作业

    第二章 操作系统是如何工作的 一.知识点总结 1.计算机的三个法宝 存储程序计算机 函数调用堆栈机制.堆栈:是C语言程序运行时必须使用的记录函数调用路径和参数存储的空间. 中断 2.堆栈相关的寄存器和 ...

  8. Part-Selenium-1

    1.在浏览器中的console输入:帮助定位 > $x('xpath表达式') > $('css表达式') 2.driver > chrome driver: https://npm ...

  9. mysql中datetime时间转字符串(避免java层映射为数字串)

    -- in_date datetime NULLDATE_FORMAT(ls.`in_date`,'%Y-%m-%d %T')AS create_time

  10. spring cloud关于feign client的调用对象列表参数、设置header参数、多环境动态参数试配

    spring cloud关于feign client的调用 1.有些场景接口参数需要传对象列表参数 2.有些场景接口设置设置权限等约定header参数 3.有些场景虽然用的是feign调用,但并不会走 ...