2015-10-19 38 views
0

我可以預期二元結果(實際,預測)的連續ROC曲線。我使用的二進制實際和二進制預測結果下面的命令,所有我得到的只是一個我使用一個inflection.The命令地塊接收者操作特徵

library(pROC) 
plot.roc(data$actual,data$predicted) 

的參考樣本數據集

Actual       
0         
1         
0         
1         
0         
1 


Predicted 
1 
0 
1 
1 
0 
1 

請讓我知道是否有任何其他解釋和繪製ROC。

+0

是您的預測值實際上是1或0?如果是這樣,你應該如何改變成像閾值以產生曲線? – Heroka

回答

1

這不是繪製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) 

enter image description here

0

如上所述,當您有分數或概率變量時,可繪製ROC曲線。根據不同的閾值,ROC治癒後繪製出不同的假陽性率/真陽性率對。你的分類器似乎產生0/1輸出,所以你只能繪製ROC空間中的一個點。有關更多信息,請參閱Fawcett 2005

這裏是ROC曲線,其中預測值是概率的一個例子:

library(pROC) 

actual <- c(0, 1, 0, 1, 0, 1) 
predicted <- c(0.35, 0.55, 0.45, 0.5, 0.55, 0.6) 

plot.roc(actual, predicted) 

enter image description here