#调整随机森林的参数(调整n_estimators随机森林中树的数量默认10个树,精度递增显著)

from sklearn import datasets
X, y = datasets.make_classification(n_samples=10000,n_features=20,n_informative=15,flip_y=.5, weights=[.2, .8]) import numpy as np
training = np.random.choice([True, False], p=[.8, .2],size=y.shape) from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import confusion_matrix n_estimator_params = range(1, 100,5)
confusion_matrixes = {}
for n_estimator in n_estimator_params:
rf = RandomForestClassifier(n_estimators=n_estimator,n_jobs=-1, verbose=True)
rf.fit(X[training], y[training])
print ("Accuracy:\t", (rf.predict(X[~training]) == y[~training]).mean()) '''
======================== RESTART: E:/python/pp138.py ========================
[Parallel(n_jobs=-1)]: Done 1 out of 1 | elapsed: 0.0s finished
[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 0.0s finished
Accuracy: 0.590083456063
[Parallel(n_jobs=-1)]: Done 6 out of 6 | elapsed: 0.1s finished
[Parallel(n_jobs=2)]: Done 6 out of 6 | elapsed: 0.0s finished
Accuracy: 0.618065783014
[Parallel(n_jobs=-1)]: Done 11 out of 11 | elapsed: 0.3s finished
[Parallel(n_jobs=2)]: Done 11 out of 11 | elapsed: 0.0s finished
Accuracy: 0.682866961217
[Parallel(n_jobs=-1)]: Done 16 out of 16 | elapsed: 0.5s finished
[Parallel(n_jobs=2)]: Done 16 out of 16 | elapsed: 0.0s finished
Accuracy: 0.692194403535
[Parallel(n_jobs=-1)]: Done 21 out of 21 | elapsed: 0.6s finished
[Parallel(n_jobs=2)]: Done 21 out of 21 | elapsed: 0.0s finished
Accuracy: 0.702012763868
[Parallel(n_jobs=-1)]: Done 26 out of 26 | elapsed: 0.9s finished
[Parallel(n_jobs=2)]: Done 26 out of 26 | elapsed: 0.0s finished
Accuracy: 0.697594501718
[Parallel(n_jobs=-1)]: Done 31 out of 31 | elapsed: 1.0s finished
[Parallel(n_jobs=2)]: Done 31 out of 31 | elapsed: 0.0s finished
Accuracy: 0.710358370152
[Parallel(n_jobs=-1)]: Done 36 out of 36 | elapsed: 1.1s finished
[Parallel(n_jobs=2)]: Done 36 out of 36 | elapsed: 0.0s finished
Accuracy: 0.704958271969
[Parallel(n_jobs=-1)]: Done 41 out of 41 | elapsed: 1.3s finished
[Parallel(n_jobs=2)]: Done 41 out of 41 | elapsed: 0.0s finished
Accuracy: 0.707412862052
[Parallel(n_jobs=-1)]: Done 46 out of 46 | elapsed: 1.5s finished
[Parallel(n_jobs=2)]: Done 46 out of 46 | elapsed: 0.0s finished
Accuracy: 0.716740304369
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.6s
[Parallel(n_jobs=-1)]: Done 51 out of 51 | elapsed: 1.8s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 51 out of 51 | elapsed: 0.0s finished
Accuracy: 0.713303878252
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.5s
[Parallel(n_jobs=-1)]: Done 56 out of 56 | elapsed: 1.8s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 56 out of 56 | elapsed: 0.0s finished
Accuracy: 0.713303878252
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.5s
[Parallel(n_jobs=-1)]: Done 61 out of 61 | elapsed: 2.0s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 61 out of 61 | elapsed: 0.0s finished
Accuracy: 0.717231222386
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.5s
[Parallel(n_jobs=-1)]: Done 66 out of 66 | elapsed: 2.3s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 66 out of 66 | elapsed: 0.0s finished
Accuracy: 0.711340206186
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.6s
[Parallel(n_jobs=-1)]: Done 71 out of 71 | elapsed: 2.5s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 71 out of 71 | elapsed: 0.0s finished
Accuracy: 0.720667648503
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.5s
[Parallel(n_jobs=-1)]: Done 76 out of 76 | elapsed: 2.4s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 76 out of 76 | elapsed: 0.0s finished
Accuracy: 0.721649484536
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.7s
[Parallel(n_jobs=-1)]: Done 81 out of 81 | elapsed: 3.0s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 81 out of 81 | elapsed: 0.0s finished
Accuracy: 0.721649484536
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.5s
[Parallel(n_jobs=-1)]: Done 86 out of 86 | elapsed: 2.8s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 86 out of 86 | elapsed: 0.0s finished
Accuracy: 0.716740304369
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.5s
[Parallel(n_jobs=-1)]: Done 91 out of 91 | elapsed: 3.1s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 91 out of 91 | elapsed: 0.0s finished
Accuracy: 0.72410407462
[Parallel(n_jobs=-1)]: Done 46 tasks | elapsed: 1.4s
[Parallel(n_jobs=-1)]: Done 96 out of 96 | elapsed: 3.1s finished
[Parallel(n_jobs=2)]: Done 46 tasks | elapsed: 0.0s
[Parallel(n_jobs=2)]: Done 96 out of 96 | elapsed: 0.0s finished
Accuracy: 0.718213058419
'''

#调整随机森林的参数(调整n_estimators随机森林中树的数量默认10个树,精度递增显著,但并不是越多越好),加上verbose=True,显示进程使用信息的更多相关文章

  1. #调整随机森林的参数(调整max_features,结果未见明显差异)

    #调整随机森林的参数(调整max_features,结果未见明显差异) from sklearn import datasets X, y = datasets.make_classification ...

  2. Linux 查找指定名称的进程并显示进程详细信息

    实际应用中可能有这样的场景:给定一个进程名称特征串,查找所有匹配该进程名称的进程的详细信息. 解决的办法是: (1) 先用pgrep [str] 命令进行模糊匹配,找到匹配该特征串的进程ID: (2) ...

  3. Sysctl命令及linux内核参数调整

        一.Sysctl命令用来配置与显示在/proc/sys目录中的内核参数.如果想使参数长期保存,可以通过编辑/etc/sysctl.conf文件来实现.    命令格式:  sysctl [-n ...

  4. sklearn中随机森林的参数

    一:sklearn中决策树的参数: 1,criterion: ”gini” or “entropy”(default=”gini”)是计算属性的gini(基尼不纯度)还是entropy(信息增益),来 ...

  5. XGBoost中参数调整的完整指南(包含Python中的代码)

    (搬运)XGBoost中参数调整的完整指南(包含Python中的代码) AARSHAY JAIN, 2016年3月1日     介绍 如果事情不适合预测建模,请使用XGboost.XGBoost算法已 ...

  6. TensorFlow实现超参数调整

    TensorFlow实现超参数调整 正如你目前所看到的,神经网络的性能非常依赖超参数.因此,了解这些参数如何影响网络变得至关重要. 常见的超参数是学习率.正则化器.正则化系数.隐藏层的维数.初始权重值 ...

  7. Galera集群server.cnf参数调整--Innodb存储引擎内存相关参数(一)

    在innodb引擎中,内存的组成主要有三部分:缓冲池(buffer pool),重做日志缓存(redo log buffer),额外的内存池(additional memory pool).

  8. paip.提升性能----jvm参数调整.txt

    paip.提升性能----jvm参数调整.txt 作者Attilax  艾龙,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.n ...

  9. Storm集群参数调整

    Supervisor 参数调整 修改${STORM_HOME}conf/storm.yaml文件内容 supervisor变更参数 slots 配置: 若storm host仅仅执行superviso ...

随机推荐

  1. Linux嵌入式 -- 内核 - 进程控制 和 调度

    1. 进程四要素 1. 有一段程序供其执行.这段程序不一定是某个进程所专有,可以与其他进程共用. 2. 有进程专用的内核空间堆栈. 3. 在内核中有一个task_struct数据结构,即通常所说的&q ...

  2. 谷歌地图OGC WMTS服务规则

    http://mt0.google.cn/vt/lyrs=s&x=0&y=0&z=1 其中:z即为瓦片的层次,0层覆盖全球:y为行,从上往下为0~2^z-1:x为列,从左往右依 ...

  3. R文件报错:cannot resolve symbol ‘R’

    今天仿照别人项目,因为不太熟悉Androidstudio,所以就照着他项目结构走,结果包名跟他的不一样,项目一直报标题这个错误,网上百度了很多也没用,不过先把网上的解决方案copy一下 请注意 ① E ...

  4. hzau 1206 MathematicalGame

    1206: MathematicalGame Time Limit: 2 Sec  Memory Limit: 1280 MBSubmit: 124  Solved: 15[Submit][Statu ...

  5. Django 基础 路由系统

    Django框架简介 MVC框架和MTV框架(了解即可) MVC,全名是Model View Controller,是软件工程中的一种软件架构模式,把软件系统分为三个基本部分:模型(Model).视图 ...

  6. hive_学习_00_资源帖

    一.官方资料 二.参考资料

  7. shell_script_查询主机名、ip地址 、DNS地址

    #!/bin/bashhostnameip=`/sbin/ifconfig eth0|grep "inet addr:"|sed 's/Bcast.*$//'g |awk -F & ...

  8. 201621123014《Java程序设计》第七周学习总结

    1. 本周学习总结 1.1 思维导图:Java图形界面总结 答: 1.2 可选:使用常规方法总结其他上课内容. 答:1.Swing组件主要分为容器组件和其他组件. 2.JFrame和JPanel都可以 ...

  9. New Concept English three (51)

    22 76 Predicting the future is notoriously difficult. Who could have imagined, in the mid 1970s, for ...

  10. javascript版前端页面RSA非对称加密解密

    最近由于项目需要做一个url传参,并在页面显示参数内容的需求,这样就会遇到一个url地址可能会被假冒, 并传递非法内容显示在页面的尴尬情况 比如xxx.shtml?server=xxx是坏人& ...