ggplot 可视化单个值的置信区间(准确率)
ggplot visualize confidence interval of single values (accuracy rates)
如果有人能告诉我如何不仅绘制每个分类器的准确性,还绘制置信区间(AccuracyLower、AccuracyUpper),我会很高兴。每当我使用 ggplot 时,绘图只会显示准确性,而不是其他值。我的数据框如下所示:
compmods <- data.frame(Model = c("SVM", "XGB", "Random forest","Neural net"), Accuracy = c(0.7324477,0.7460202,0.7634408,0.7420827), AccuracyLower = c(0.7297001,0.7433180,0.7608018,0.7393670), AccuracyUpper = c(0.7351819,0.7487083,0.7660646,0.7447845))
#this does not produce the desired plot:
compmods %>%
ggplot(aes(x = Model, y = Accuracy)) + theme_bw() +
geom_point(aes(Model, AccuracyLower), shape = 20) +
geom_point(aes(Model, AccuracyUpper))+
geom_point() +
ylim(0, 1) +
geom_hline(yintercept = 0.695628,
color = "Red") +
labs(title = "Average classifier accuracy compared to no information rate")
这是您要找的东西吗:
compmods %>%
ggplot(aes(Model)) +
geom_errorbar(aes(ymin = AccuracyLower, ymax = AccuracyUpper)) +
geom_point(aes(y = Accuracy), color = "red", size = 5)
作为旁注,您的绘图也工作得很好 - 它绘制了所有点,但它们非常接近所以它们重叠(如果比例从 0 到 1)
如果有人能告诉我如何不仅绘制每个分类器的准确性,还绘制置信区间(AccuracyLower、AccuracyUpper),我会很高兴。每当我使用 ggplot 时,绘图只会显示准确性,而不是其他值。我的数据框如下所示:
compmods <- data.frame(Model = c("SVM", "XGB", "Random forest","Neural net"), Accuracy = c(0.7324477,0.7460202,0.7634408,0.7420827), AccuracyLower = c(0.7297001,0.7433180,0.7608018,0.7393670), AccuracyUpper = c(0.7351819,0.7487083,0.7660646,0.7447845))
#this does not produce the desired plot:
compmods %>%
ggplot(aes(x = Model, y = Accuracy)) + theme_bw() +
geom_point(aes(Model, AccuracyLower), shape = 20) +
geom_point(aes(Model, AccuracyUpper))+
geom_point() +
ylim(0, 1) +
geom_hline(yintercept = 0.695628,
color = "Red") +
labs(title = "Average classifier accuracy compared to no information rate")
这是您要找的东西吗:
compmods %>%
ggplot(aes(Model)) +
geom_errorbar(aes(ymin = AccuracyLower, ymax = AccuracyUpper)) +
geom_point(aes(y = Accuracy), color = "red", size = 5)
作为旁注,您的绘图也工作得很好 - 它绘制了所有点,但它们非常接近所以它们重叠(如果比例从 0 到 1)