#调整随机森林的参数(调整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. JavaWeb -- Servlet+JSP+JavaBean(MVC)模式

    Servlet+JSP+JavaBean(MVC)模式适合开发复杂的web应用,在这种模式下,servlet负责处理用户请求,jsp负责数据显示,javabean负责封装数据. Servlet+JSP ...

  2. 在CentOS6.4中安装配置LAMP环境的详细步骤 - Leroy-LIZH

    本文详细介绍了CentOS6.4系统中安装LAMP服务并对其进行配置的过程,即安装Apache+PHP+Mysql,参照了网上大神的设置,其他Linux发行系统可以参考~ 在本文中部分命令操作需要ro ...

  3. DH03-单一职责原则

    模式简介 就一个类而言,应该仅有一个引起它变化的原因.不要存在多于一个导致类变更的原因.遵循单一职责原则.分别建立两个类T1和T2,使T1完成P1功能,T2完成P2功能.当修改T1时,不会使职责P2发 ...

  4. python之单元测试框架—unittest

    一. 什么是单元测试?单元测试的对象是什么? 1: 什么是单元测试? 按照定义,单元测试就是对单个模块或者单个类或者单个函数进行测试,一般是开发做的,按照阶段分,一般就是单元测试.集成测试.系统测试. ...

  5. excel中日期设置星期

    在设置日期格式中-自定义中-设置填入yyyy-mm-dd [$-804]aaa;@ 即可.

  6. python--*args和**kwargs可变参数

    先来看个例子: #! /usr/bin/env python #coding=utf-8 def foo(*args, **kwargs): print('args=',args) print('kw ...

  7. AngularJS-webapp($q)

    $q延迟加载: 当一个数据需要请求多次,后面一个数据需要前面请求的数据时,我们就可以通过延迟加载进行数据传递 如下代码: 首先:我们需要得到职位信息: { "id": " ...

  8. Linux 线程同步的三种方法(互斥锁、条件变量、信号量)

    互斥锁 #include <cstdio> #include <cstdlib> #include <unistd.h> #include <pthread. ...

  9. hihocoder#1148 : 2月29日 计算闰年的个数

    计算到某年为止的闰年数,其实很简单.设要计算的年为A,则到A年为止(含A年)的闰年数为: 闰年数=INT(A/)-INT(A/)+INT(A/) 这里:INT为取整数函数 #include <c ...

  10. Python 3.5 socket OSError: [Errno 101] Network is unreachable

    /******************************************************************************** * Python 3.5 socke ...