我想要计算精度和召回,并从二进制数据集(事件发生/不发生)在R中创建精确召回图。我的数据与下面的示例类似。
truth <- rbinom(200, 1, 0.9)
pred_1 <- rbinom(200, 1, 0.8)
pred_2 <- rbinom(200, 1, 0.7)
dat <- data.frame(truth, pred_1, pred_2)
head(dat)
#> truth pred_1 pred_2
#> 1 1 1 1
#> 2 1 1 1
#> 3 1 1 0
#> 4 0 1 1
#> 5 1 0 1
#> 6 1 1 1本质上,我的目标是评估pred_1和pred_2的精确性和召回率,以确定与truth (标准)相比的“事件”(标识为1)。我知道在R中有一些软件包/函数可以可视化精确/回忆,但我不确定这个例子的最佳方法。我从pr_curve包中看到了yardstick函数,但我不知道如何将文档中的示例应用到自己的数据集中。任何关于我如何解决这个问题的建议都将是非常有用和感激的。
发布于 2022-03-04 11:35:39
您可以使用以下代码:
library(yardstick)
truth <- rbinom(200, 1, 0.9)
pred_1 <- rbinom(200, 1, 0.8)
pred_2 <- rbinom(200, 1, 0.7)
dat <- data.frame(truth = as.factor(truth), pred_1 = as.numeric(pred_1), pred_2 = as.numeric(pred_2))
autoplot(pr_curve(dat, truth, pred_1))输出:

https://stackoverflow.com/questions/71350724
复制相似问题