這不是繪製roc曲線下面積的正確方法。以這種方式繪製它會給你所有點的50%,因爲你不提供任何閾值。
ROC曲線的整點是通過繪製每個閾值的特異性和敏感度(檢查here)來提供模型準確性更全面的視圖。閾值(取值介於0和1之間,因爲它是一個概率閾值)是根據其相關概率確定測試用例爲0或1的原因。作爲具有40%閾值的示例,任何概率超過0.4的預測情況將被分類爲1(成功)並且小於0.4作爲0(失敗)。在ROC曲線的計算和繪圖中使用根據各種閾值收集的特異性和敏感性。
爲例(從PROC文檔),以使用plot.roc功能,你可以這樣做:
#load the data
data(aSAH)
#Create a model so that you get the sensitivities, specificities for different
#thresholds
rocdata <- roc(aSAH$outcome, aSAH$s100b,
levels=c("Good", "Poor"))
> str(rocdata)
List of 15
$ percent : logi FALSE
$ sensitivities : num [1:51] 1 0.976 0.976 0.976 0.976 ...
$ specificities : num [1:51] 0 0 0.0694 0.1111 0.1389 ...
$ thresholds : num [1:51] -Inf 0.035 0.045 0.055 0.065 ...
$ direction : chr "<"
#and so on...
然後你就可以繪製它爲:
plot.roc(rocdata)
是您的預測值實際上是1或0?如果是這樣,你應該如何改變成像閾值以產生曲線? – Heroka