[R] NAs error in caret function

javed khan
2022-04-20T19:50:52Z

Caret produce the error: Something is wrong; all the Accuracy metric values
are missing:
    logLoss         AUC          prAUC        Accuracy       Kappa
 Min.   : NA   Min.   : NA   Min.   : NA   Min.   : NA   Min.   : NA
 1st Qu.: NA   1st Qu.: NA   1st Qu.: NA   1st Qu.: NA   1st Qu.: NA
 Median : NA   Median : NA   Median : NA   Median : NA   Median : NA

We (group of three) working on an assignment and could not fix this error
from a few days. The error comes with the majority of the models while with
a few model (e.g. nb), the code works. The data is text-based
classification.

Some Warnings are:

Warning messages:
1: In train.default(y = train_label, x = train_x, method = "pls",  ...
:
  The metric "ROC" was not in the result set. logLoss will be used
instead.
2: model fit failed for Fold01.Rep1: ncomp=3 Error in
`[[<-.data.frame`(`*tmp*`, i, value = structure(c(1L, 1L, 1L,  :
  replacement has 320292 rows, data has 1148

3: model fit failed for Fold02.Rep1: ncomp=3 Error in
`[[<-.data.frame`(`*tmp*`, i, value = structure(c(1L, 1L, 1L,  :
  replacement has 320013 rows, data has 1147

4: model fit failed for Fold03.Rep1: ncomp=3 Error in
`[[<-.data.frame`(`*tmp*`, i, value = structure(c(1L, 1L, 1L,  :
  replacement has 320013 rows, data has 1147

5: model fit failed for Fold04.Rep1: ncomp=3 Error in
`[[<-.data.frame`(`*tmp*`, i, value = structure(c(1L, 1L, 1L,  :
  replacement has 320292 rows, data has 1148

6: model fit failed for Fold05.Rep1: ncomp=3 Error in
`[[<-.data.frame`(`*tmp*`, i, value = structure(c(1L, 1L, 1L,  :
  replacement has 320013 rows, data has 1147

7: model fit failed for Fold06.Rep1: ncomp=3 Error in
`[[<-.data.frame`(`*tmp*`, i, value = structure(c(1L, 1L, 1L,  :
  replacement has 320013 rows, data has 1147



Code is


m= train(y = train_label, x = train_x,
      method = "pls" ,
      metric = "Accuracy",
      ## #  preProc = c("center", "scale", "nzv"),
      trControl = ctrl)

p=predict(m, test_x)
confusionMatrix(p, as.factor(test_label))

	[[alternative HTML version deleted]]