r - custom metric using ROCR package in caret -


here minimal example of problem. want use recall performance metric in caret

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) 

however, error

 error in rocr::prediction(data$pred, as.numeric(data$obs) - 1, "rec") :   format of predictions invalid. 

i haven't used package in while based on example in ?prediction, need pass class probabilities (and train doesn't generate these unless use option classprobs = true in traincontrol) in argument predictions. once have done that, use proper column of data input prediction function.

also, should read the paper on subject because think need call performance recall.

max


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -