这是我的问题的最小例子。我想将Recall用作插入符号中的性能指标
library(caret)
set.seed(1234)
x <- matrix(rnorm(10),nrow=5,ncol=2 )
y <- factor(c("y","n","y","y","n"))
my.metric <- function (data,
lev = NULL,
model = NULL) {
out <- ROCR::performance(ROCR::prediction(data$pred, as.numeric(data$obs)-1,"rec"))
names(out) <- "REC"
out
}
myControl <- trainControl(summaryFunction = my.metric, method="repeatedcv", number=10, repeats=2)
fit <- train(y=y,x=x, metric = "REC",method="gbm", trControl = myControl)
然而,我收到此错误
Error in ROCR::prediction(data$pred, as.numeric(data$obs) - 1, "rec") :
Format of predictions is invalid.