caret - error - Something is wrong - all the ROC metric values are missing:

2.9k views Asked by At

i am using the caret package. At specific instances, as for example, but not exclusively per the example below, caret will produce the following error:

Something is wrong; all the ROC metric values are missing:
Error in train.default(x, y, weights = w, ...) : Stopping

The strange thing is that caret might do this with nearly identical calls. E.g. - the first call per below works, the second call gives an error. i have had similar issue when i included e.g. the Verbose argument, keeping all things equal, or when i run specific packages in caret (e.g. SVMs).

I have read that the issue might be definition of the class variable, but my main variable is a standard factor with 2 levels, e.g. (Factor w/ 2 levels "NP","P": 1 1 1 1 1 1 1 1 1 1 ...).

Does anyone have any tips?

(apologies for not including reproducible example)

Call 1
gbmFit1 <- train(class ~., data = dt_fulltrain,method = "gbm",metric="ROC",trControl = fitControl)

Call2
gbmFit1 <- train(class ~., data = dt_fulltrain,method = "gbm",metric="ROC",trControl = fitControl, strata = dt_fulltrain$class, sampsize = rep(nmin, 2))
2

There are 2 answers

0
Anaxagoras On

I had a similar problem. Without having a reproducible version of yours, I can't be sure that this will solve it.

For future readers, however, you might try checking your data for NA, NaN, and Inf. In my case, I had some cells that contained Inf. Removing those rows, solved the problem.

0
KaanKaant On

I've had a similar problem and found that loading the pROC library (https://cran.r-project.org/web/packages/pROC/index.html) before training solves the issue.