如何使用R

发布于 2025-02-12 17:23:13 字数 457 浏览 1 评论 0原文

我想通过在Randomforest中获得每个类别的分类概率。

(1)这将输出单个输出,但其类型为响应,而不是概率

predict(rf_cl, newdata, predict.all=TRUE)$individual 

(2)此输出概率,但它属于森林所有树:

predict(rf_cl, newdata, type="prob")

(3)当我尝试此树时,我获得了与第一个输出相同的输出。

predict(rf_cl, newdata, predict.all=TRUE, type="prob")$individual 

我正在网上搜索很长时间。但是没有用。请帮助或尝试给出一些想法。提前致谢。

I want to get classification probabilities of each class by each tree in the randomForest.

(1) This outputs individual outputs but its type is response, not probabilities:

predict(rf_cl, newdata, predict.all=TRUE)$individual 

(2) This outputs probabilities but it belongs to the forest not all trees:

predict(rf_cl, newdata, type="prob")

(3) When I tried this, I got the same output as the first one.

predict(rf_cl, newdata, predict.all=TRUE, type="prob")$individual 

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那小子欠揍 2025-02-19 17:23:14

Randomforest的成员决策树决策树集合做出“纯”预测。也就是说,获胜类别的概率是1.0,所有其他类别的概率均为0.0

随机森林使用投票机制计算总概率 - 每个类别的“纯”预测(又称投票)的数量除以成员决策树的总数。知道这将有助于您选择决策树的数量,以达到总概率的所需“精度”,并避免任何关系。例如,在建模二进制目标时,您应该选择奇数的成员决策树,以避免0.5 vs. 0.5 tie。

The member decision trees of a randomForest decision tree ensemble make "pure" predictions. That is, the probability of the winning category is 1.0, and the probabilities of all other categories are 0.0.

The random forest computes the aggregate probability using the voting mechanism - the number of "pure" predictions (aka votes) for each class, divided by the total number of member decision trees. Knowing this will help you choose the number of decision trees in order to achieve the desired "precision" of aggregate probabilities, and avoid any ties. For example, when modeling a binary target, then you should choose an odd number of member decision trees to avoid a 0.5 vs. 0.5 tie.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文