如何对预测的二进制结果进行投票

问题描述 投票:0回答:1

考虑到泰坦尼克号数据集,我创建了几个生存预测,并且我想基于投票系统创建最终生存,这意味着,如果大多数预测都规定该乘客幸存下来,则最终结果为1,否则为0。] >

> str(temp)
'data.frame':   179 obs. of  3 variables:
 $ predictions_ldm    : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
 $ predictions_qda    : Factor w/ 2 levels "0","1": 1 1 1 1 2 1 1 1 1 1 ...
 $ predictions_glm_age: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
> temp[c(4,5,12),]
   predictions_ldm predictions_qda predictions_glm_age
4                0               0                   0
5                0               1                   0
12               1               1                   0

我希望结果是

> temp[c(4,5,12),]
   predictions_ldm predictions_qda predictions_glm_age            Survived
4                0               0                   0                   0
5                0               1                   0                   0
12               1               1                   0                   1

我该如何实现?

考虑泰坦尼克号数据集,我创建了几个生存预测,并且我想基于投票系统创建最终生存,这意味着,如果大多数预测都规定了...

r prediction
1个回答
0
投票

这是使用dplyr的不必要的复杂解决方案,但我真的很想使用c_across()。首先,我需要将因子转换为保持0-1值的整数。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.