I am trying to make a model using different methods as below in R.
train_control <- caret::trainControl(method = "cv", number = 10)
Result <- train(Service.Int.Code~., data = DTA, tuneLength=2, trControl=train_control, method="rpart")
Why do I get the following Error?
Something is wrong; all the Accuracy metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :3 NA's :3
Error: Stopping
BTW, I do not have missing values. This is the first 30 rows of my data. The total number of row is ~150k. With KNN, I also get the same error.
DTA<-structure(list(Adm.Code = c(2716882L, 2716882L, 2716884L, 2716884L,
2716884L, 2716885L, 2716885L, 2716885L, 2716885L, 2716886L, 2716886L,
2716886L, 2716886L, 2716889L, 2716889L, 2716889L, 2716896L, 2716896L,
2716896L, 2716896L, 2716899L, 2716899L, 2716899L, 2716907L, 2716907L,
2716907L, 2716907L, 2716908L, 2716908L, 2716908L), Sex = c(1L,
1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L), Old = c(0L,
0L, 23L, 23L, 23L, 49L, 49L, 49L, 49L, 24L, 24L, 24L, 24L, 22L,
22L, 22L, 35L, 35L, 35L, 35L, 29L, 29L, 29L, 37L, 37L, 37L, 37L,
54L, 54L, 54L), BloodGroup = c(0, 0, 20, 20, 20, 20, 20, 20,
20, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0), DiagCode = c(2000L, 2000L, 2000L, 2000L, 2000L, 2000L,
2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L,
2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L,
2000L, 2000L, 2000L, 2000L, 2000L, 2000L), DiseaseTag = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Doctor.Code = c(13545L,
13545L, 13545L, 13545L, 13545L, 13545L, 13545L, 13545L, 13545L,
13545L, 13545L, 13545L, 13545L, 13545L, 13545L, 13545L, 13545L,
13545L, 13545L, 13545L, 13545L, 13545L, 13545L, 13545L, 13545L,
13545L, 13545L, 13545L, 13545L, 13545L), Mon = c(1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1), Service.Int.Code = structure(c(1L, 2L, 1L, 2L,
3L, 1L, 2L, 4L, 3L, 1L, 2L, 4L, 3L, 1L, 2L, 3L, 1L, 2L, 4L, 3L,
1L, 2L, 3L, 1L, 2L, 4L, 3L, 1L, 2L, 4L), .Label = c("A", "B",
"C", "D", "E", "F", "G", "H", "I", "J"), class = "factor"), NumLabels = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0_100",
"100_250", "250_500", "500More"), class = "factor")), row.names = c(NA,
-30L), class = c("tbl_df", "tbl", "data.frame"))