2013-11-21 42 views
1

我在R中使用ROCR包 但是我得到了錯誤「預測(預測,標籤): 預測的格式無效」。預測的格式在R中無效ROCR包

請告訴我解決方案。

這裏是代碼:

install.packages("ROCR", dependencies=TRUE) 
install.packages("vcd", dependencies=TRUE) 
library(ROCR) 
library(vcd) 
library(boot) 

setwd("/Users/Documents/R") 

presence <- read.csv("sampleAverages.csv") 
background <- read.csv("amplePredictions.csv") 
pp <- presence$Logistic.prediction    # get the column of predictions 
testpp <- pp[presence$Test.or.train=="test"]  # select only test points 
trainpp <- pp[presence$Test.or.train=="train"] # select only train points 
bb <- background$logistic 

combined <- c(testpp, bb)         # combine into a single  vector 
label <- c(rep(1,length(testpp)),rep(0,length(bb))) # labels: 1=present, 0=random 
pred <- prediction(combined, label)     # labeled predictions 
perf <- performance(pred, "tpr", "fpr")    # True/false positives, for ROC curve 
plot(perf, colorize=TRUE)         # Show the ROC curve 
performance(pred, "auc")@y.values[[1]]   # Calculate the AUC 
+0

這不會給沒有數據運行。 –

+0

錯誤在哪裏?必須做很多沒有數據。 ROCR小插曲有很好的一步一步的例子[here](http://rocr.bioinf.mpi-sb.mpg.de/ROCR.pdf) –

回答

0

這可能是因爲你有錯誤的類數據。嘗試將預測數據修改爲像這樣組合的一列[,2]或標籤[,2]

0

檢查兩個對象(標籤和組合)的類別,您注意到它們不相同。然後就可以將子集與不同尺寸與dimRid < - 結合[1]