随机森林采用多数表决的一种,最终表决结果不是树上的类别(class)频率,而是树上的各类别概率的平均值

在分类问题中,RF分类器根据多数投票(例如,投票结果)给出最终答复.是或否.

另一方面,在Python中,我还可以看到带有事件最终概率的向量,例如0,83.如果我有1000个估计量,每棵树有1000个概率的平均值,那么该概率如何计算?

clf = RandomForestClassifier(max_depth = 4, min_samples_split=2, n_estimators = 200, random_state = 1)

clf.fit(train[columns], train["churn"])

predictions = clf.predict(test[columns])

predicted_probs = clf.predict_proba(test[columns])

print(predicted_probs)

test = pd.concat([test, pd.DataFrame(predicted_probs, columns=['Col_0', 'Col_1'])], axis=1)

解决方法:

is the mean of 1000 probabilities, from each tree?

是的.

向量显示所有树中每个选定类别的平均概率. Scikit RF分类中的最终投票将为所有树的给定输入选择具有最高平均概率的类别.

因此,如果对于双类别数据集,对于给定的样本/输入,C1和C2在分别标记为1和2的树上的概率分别为0.3、0.7和0.5、0.5. C1的平均概率为0.4,而C2的平均概率为0.4.的0.6.

C2是该输入的选定类别,因为它在两棵树上的平均概率最高.

您还可以查看ForestClassifiers的predict方法的源代码.从该方法的__doc__:

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.

概括地说,这是多数表决的一种,表决权重不是树上的class频率,而是树上的平均值.


https://blog.csdn.net/weixin_39622289/article/details/111766934

https://blog.lzys.cc/p/1289523.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值