sklearn 随机森林方法
Notes The default values for the parameters controlling the size of the trees (e.g. max_depth, min_samples_leaf, etc.) lead to fully grown and unpruned trees
which can potentially be very large on some data sets. To reduce memory consumption, the complexity and size of the trees should be controlled by setting
those parameter values. The features are always randomly permuted at each split. Therefore, the best found split may vary, even with the same training data, max_features=n_features
and bootstrap=False, if the improvement of the criterion is identical for several splits enumerated during the search of the best split. To obtain a
deterministic behaviour during fitting, random_state has to be fixed. References [R157]
Breiman, “Random Forests”, Machine Learning, (), -, .
Methods
apply (X) |
Apply trees in the forest to X, return leaf indices. |
decision_path (X) |
Return the decision path in the forest |
fit (X, y[, sample_weight]) |
Build a forest of trees from the training set (X, y). |
get_params ([deep]) |
Get parameters for this estimator. |
predict (X) |
Predict class for X. |
predict_log_proba (X) |
Predict class log-probabilities for X. |
predict_proba (X) |
Predict class probabilities for X. |
score (X, y[, sample_weight]) |
Returns the mean accuracy on the given test data and labels. |
set_params (**params) |
Set the parameters of this estimator. |
predict
(X)-
Predict class for X.
The predicted class of an input sample is a vote by the trees in the forest, weighted by their probability estimates. That is, the predicted class is the one with highest mean probability estimate across the trees.
Parameters: X : array-like or sparse matrix of shape = [n_samples, n_features]
The input samples. Internally, its dtype will be converted to
dtype=np.float32
. If a sparse matrix is provided, it will be converted into a sparsecsr_matrix
.Returns: y : array of shape = [n_samples] or [n_samples, n_outputs]
The predicted classes.
predict_log_proba
(X)-
Predict class log-probabilities for X.
The predicted class log-probabilities of an input sample is computed as the log of the mean predicted class probabilities of the trees in the forest.
Parameters: X : array-like or sparse matrix of shape = [n_samples, n_features]
The input samples. Internally, its dtype will be converted to
dtype=np.float32
. If a sparse matrix is provided, it will be converted into a sparsecsr_matrix
.Returns: p : array of shape = [n_samples, n_classes], or a list of n_outputs
such arrays if n_outputs > 1. The class probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_.
predict_proba
(X)-
Predict class probabilities for X.
The predicted class probabilities of an input sample are computed as the mean predicted class probabilities of the trees in the forest. The class probability of a single tree is the fraction of samples of the same class in a leaf.
Parameters: X : array-like or sparse matrix of shape = [n_samples, n_features]
The input samples. Internally, its dtype will be converted to
dtype=np.float32
. If a sparse matrix is provided, it will be converted into a sparsecsr_matrix
.Returns: p : array of shape = [n_samples, n_classes], or a list of n_outputs
such arrays if n_outputs > 1. The class probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_.
score
(X, y, sample_weight=None)-
Returns the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Parameters: X : array-like, shape = (n_samples, n_features)
Test samples.
y : array-like, shape = (n_samples) or (n_samples, n_outputs)
True labels for X.
sample_weight : array-like, shape = [n_samples], optional
Sample weights.
Returns: score : float
Mean accuracy of self.predict(X) wrt. y.
From Sklearn:
http://sklearn.apachecn.org/cn/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier
sklearn 随机森林方法的更多相关文章
- 使用基于Apache Spark的随机森林方法预测贷款风险
使用基于Apache Spark的随机森林方法预测贷款风险 原文:Predicting Loan Credit Risk using Apache Spark Machine Learning R ...
- 解决sklearn 随机森林数据不平衡的方法
Handle Imbalanced Classes In Random Forest Preliminaries # Load libraries from sklearn.ensemble im ...
- sklearn_随机森林random forest原理_乳腺癌分类器建模(推荐AAA)
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...
- 随机森林random forest及python实现
引言想通过随机森林来获取数据的主要特征 1.理论根据个体学习器的生成方式,目前的集成学习方法大致可分为两大类,即个体学习器之间存在强依赖关系,必须串行生成的序列化方法,以及个体学习器间不存在强依赖关系 ...
- 决策树-预测隐形眼镜类型 (ID3算法,C4.5算法,CART算法,GINI指数,剪枝,随机森林)
1. 1.问题的引入 2.一个实例 3.基本概念 4.ID3 5.C4.5 6.CART 7.随机森林 2. 我们应该设计什么的算法,使得计算机对贷款申请人员的申请信息自动进行分类,以决定能否贷款? ...
- 随机森林入门攻略(内含R、Python代码)
随机森林入门攻略(内含R.Python代码) 简介 近年来,随机森林模型在界内的关注度与受欢迎程度有着显著的提升,这多半归功于它可以快速地被应用到几乎任何的数据科学问题中去,从而使人们能够高效快捷地获 ...
- 随机森林学习-sklearn
随机森林的Python实现 (RandomForestClassifier) # -*- coding: utf- -*- """ RandomForestClassif ...
- sklearn中的随机森林
阅读了Python的sklearn包中随机森林的代码实现,做了一些笔记. sklearn中的随机森林是基于RandomForestClassifier类实现的,它的原型是 class RandomFo ...
- kaggle 欺诈信用卡预测——不平衡训练样本的处理方法 综合结论就是:随机森林+过采样(直接复制或者smote后,黑白比例1:3 or 1:1)效果比较好!记得在smote前一定要先做标准化!!!其实随机森林对特征是否标准化无感,但是svm和LR就非常非常关键了
先看数据: 特征如下: Time Number of seconds elapsed between each transaction (over two days) numeric V1 No de ...
随机推荐
- nginx 域名跳转 Nginx跳转自动到带www域名规则配置、nginx多域名向主域名跳转
nginx 域名跳转 Nginx跳转自动到www域名规则配置,如果设置使 mgcrazy.com域名在用户访问的时候自动跳转到 www.mgcrazy.com呢?在网上找了好多资料都没有一个完整能解决 ...
- NHibernate 继承映射(第十六篇)
在NHibernate的映射中,关于继承的映射策略有3种方式 单表继承 类表继承 具体表继承 另外还有一种比较特别的多态映射 隐式多态 下面分别来阐述NHibernate继承映射的各种策略要点. 一. ...
- 基于tiny4412的Linux内核移植 -- PWM子系统学习(七)
作者信息 作者: 彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台简介 开发板:tiny4412ADK + S700 + 4GB Flash 要移植的内核版本 ...
- JS/JQuery判断是否移动设备+JS/JQuery判断浏览器类型
原文:https://blog.csdn.net/Little_Stars/article/details/48624669 JS代码如下(点击事件依赖JQuery): //判断设备类型 $(&quo ...
- iOS:在使用Cocoapods安装shareSDK时出现的link路径错误
CocoaPods 错误 target overrides the `OTHER_LDFLAGS`... Xcode 升级到 6.0 后,更新 CocoaPods,出现了如下的警告 [!] The ` ...
- RenderMonkey 练习 第二天 【opengl 光照模型】
光照模型 3D渲染中, 物体表面的光照计算公式为: I = 环境光(Iambient) + 漫反射光(Idiffuse) + 镜面高光(Ispecular); 其中,环境光(ambient)计算公式为 ...
- thinkphp5.0 中使用第三方无命名空间的类库
ThinkPHP5建议所有的扩展类库都使用命名空间定义,如果你的类库没有使用命名空间,则不支持自动加载,必须使用Loader::import方法先导入文件后才能使用. 首先要在文件头部使用loader ...
- 快速实现一个生产者-消费者模型demo
package jesse.test1; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Blo ...
- python从数据库获取全量数据的方法
python从数据库获取全量数据的方法 学习了:https://blog.csdn.net/lom9357bye/article/details/79503658 原文膜拜: import psyco ...
- ssh认证
密钥认证 密码验证会造成账户口令的外泄,不安全,基于账号的保密性考虑,可以采用密钥验证实现远程连接. Linux--Linux 1.Linux客户端主机上生成密钥文件 ssh-keygen -t rs ...