R与ROCR包中的预测格式无效

问题描述 投票:1回答: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
r maxent
2个回答
0
投票

这可能是因为你有错误的数据类。尝试将预测数据修改为仅一列,如此组合[,2]或标签[,2]


0
投票

检查两个对象的类(标签和组合)你注意到它们是不一样的。然后,您可以使用dimRid < - combined [,1]对具有不同维度的那个进行子集化

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