更改R中ROC的刻度线

问题描述 投票:1回答:1
library(ROCR)
data(ROCR.simple)
pred = prediction( ROCR.simple$predictions, ROCR.simple$labels)
roc.perf = performance(pred, measure = "tpr", x.measure = "fpr")
plot(roc.perf)

如何将x和y轴的比例更改为百分比而不是十进制?

注意:我想使用基本R解决方案,或使用ROCR软件包中提供的解决方案。由于我处于封闭的网络上,因此无法访问GGPLOT2库。

r plot axis roc
1个回答
0
投票

如果查看.plot.performance的代码(用于绘制预测),它们会将x和y值存储在@ x.values和@ y.values下。

所以您可以这样做:

plot([email protected][[1]]*100,[email protected][[1]]*100)

要获得%的刻度,请执行:

plot([email protected][[1]],[email protected][[1]],
xaxt="n",yaxt="n",type="l",ylab="True Positive Rate",
xlab="False Positive Rate")

TICKS=seq(0,1,by=0.2)
LABELS=paste0(100*TICKS,"%")
axis(side=2,at=TICKS,label=LABELS)
axis(side=1,at=TICKS,label=LABELS)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.