2

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
4

2 に答える 2

0

これは、データのクラスが間違っていることが原因である可能性があります。この結合[,2]またはラベル[,2]のように、予測データを1列だけに変更してみてください

于 2015-04-12T21:00:44.297 に答える
0

2 つのオブジェクト (ラベルと結合) のクラスを確認すると、それらが同じではないことがわかります。次に、 dimRid <- combined[,1]を使用して異なる次元のものをサブセット化できます

于 2016-08-08T01:26:24.947 に答える