Issue using 'ROC' metric in caret train function in R

谁说我不能喝 提交于 2019-12-31 05:37:25

问题


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)

回答1:


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.



来源:https://stackoverflow.com/questions/30498997/issue-using-roc-metric-in-caret-train-function-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!