0

I have an imbalanced data set with two classes therefore I thought I could use ROC as a metric instead of Accuracy to tune my model in R using caret package (I am trying different methods such as rpart, rf..etc). I thought we could extract probabilities and use ROC as a metric in decision tree type algorithms as well using caret. I illustrate my problem using a data set in caret below. There are three classes in this data but I redefined and created two classes for illustration purposes. I don't understand why the below code gives this error (I keep getting the same error when I change the method). I appreciate your help.

'Error in train.default(x, y, weights = w, ...) : final tuning parameters could not be determined In addition: Warning messages: 1: In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, : There were missing values in resampled performance measures. 2: In train.default(x, y, weights = w, ...) : missing values found in aggregated results'

library(caret) 
data(iris)

iris$Species=as.character(iris$Species)
iris$Species[which(iris$Species=='virginica')]='versicolor'
iris$Species=as.factor(iris$Species)

fitControl <- trainControl(method = "cv",number=5,classProbs = TRUE,summaryFunction = twoClassSummary)

RF=train(Species ~ ., data = iris, method="rpart",metric="ROC", trControl=fitControl)
milos.ai
  • 3,882
  • 7
  • 31
  • 33
KTY
  • 709
  • 1
  • 9
  • 17
  • The code above works for me. What is the actual error? – chupvl May 28 '15 at 07:01
  • This is the error I get. It doesn't work for me for any method. I don't know why – KTY May 29 '15 at 19:22
  • Error in train.default(x, y, weights = w, ...) : final tuning parameters could not be determined In addition: Warning messages: 1: In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, : There were missing values in resampled performance measures. 2: In train.default(x, y, weights = w, ...) : missing values found in aggregated results' – KTY May 29 '15 at 19:22

1 Answers1

0

It might be a problem with your versions of r and caret. When you update your caret package, make sure that your version of r is kept updated as well.

I had this error before and updating r version solved it.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
chong c
  • 16