使用sklearn实现随机森林分类

性感官方,在线文档

form sklearn.ensemble import RandomForestClassifier as rfc

参数

RFC需要调参可以分为两部分,一部分是bagging参数,另外一部分是决策树的参数。
n_estimators 基学习器的数量。
criterion ‘gini’ or ‘entropy’
max_depth 单树的最大深度
min_samples_split 小于该值就不分叉了
min_samples_leaf 不太懂
max_features ‘auto’,‘log2’,‘sqrt’,int ,float
min_weight_fraction_leaf不太懂
max_leaf_nodes限制叶子数量
min_impurity_decrease 垃圾分叉淘汰
min_impurity_split 预剪枝要求
bootstrap True 不适用袋外样本进行建模
oob_score 是否使用袋外样本进行评估
n_jobs 我就一核,爱咋咋地
random_state random_state
verbose Controls the verbosity when fitting and predicting.
warm_start:略
class_weight 少数民族万岁
ccp_alpha 不太懂
max_samples 当bootstrap is True,控制样本比例

属性

base_estimator:基学习器
n_features_:使用的特征数量
estimators_:所有的基学习器list
oob_score_:带外数据评估分数

方法

.fit 训练
predict 预测
predict_proba预测,返回概率
predict_log_proba 预测,返回log概率
score 返回准确率

猜你喜欢

转载自blog.csdn.net/weixin_44414593/article/details/107545569
今日推荐