博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sklearn 随机森林方法
阅读量:4601 次
发布时间:2019-06-09

本文共 4016 字,大约阅读时间需要 13 分钟。

NotesThe 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, 45(1), 5-32, 2001.

Methods

(X) Apply trees in the forest to X, return leaf indices.
(X) Return the decision path in the forest
(X, y[, sample_weight]) Build a forest of trees from the training set (X, y).
([deep]) Get parameters for this estimator.
(X) Predict class for X.
(X) Predict class log-probabilities for X.
(X) Predict class probabilities for X.
(X, y[, sample_weight]) Returns the mean accuracy on the given test data and labels.
(**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 sparse csr_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 sparse csr_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 sparse csr_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
(Xysample_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

转载于:https://www.cnblogs.com/Allen-rg/p/9577848.html

你可能感兴趣的文章
Docker CE 安装
查看>>
HR面试总结
查看>>
Yahoo!团队:网站性能优化的35条黄金守则(转)
查看>>
redis 基本操作
查看>>
Windows下安装Redis服务
查看>>
Sublime的Package Control的安装
查看>>
【HDOJ】2155 小黑的镇魂曲
查看>>
Mininet实验 脚本实现控制交换机行为
查看>>
c# 获取程序运行的根目录
查看>>
Java之匿名内部类详解
查看>>
adb 命令模拟按键事件
查看>>
Codeforces Round #436 D. Make a Permutation!
查看>>
scp的使用
查看>>
React组件绑定this的四种方式
查看>>
Jquery操作select
查看>>
利用Git将项目传到GitHub上
查看>>
转摘-谈谈后端业务系统的微服务化改造
查看>>
搜索引擎优化
查看>>
linux文件系统
查看>>
mysql以zip安装,解决the service already exists
查看>>