when fitting a BART model via bartMachine
package I get the title error.
Here is the code and dput:
#Response must be a factor
train$occ <- as.factor(train$occ)
levels(train$occ) <- c("C0", "C1")
#Creating a tuning grid
tune_grid <- expand.grid(num_trees = c(50, 100, 200),
k = c(2, 3),
alpha = 0.95,
beta = 2,
nu = 3)
#Using caret for cross-validation
train_control <- trainControl(method = "cv",
number = 10,
classProbs = TRUE,
summaryFunction = twoClassSummary,
allowParallel = TRUE)
#Starting cluster
cluster <- makeCluster(8)
registerDoParallel(cluster)
#Running the BRT model
#Model training here
bart_train <- caret::train(x = train[, 5:9],
y = train$occ,
method = "bartMachine",
metric = "ROC",
trControl = train_control,
tuneGrid = tune_grid)
#Ending cluster
stopCluster(cluster)
registerDoSEQ()
Now the dput from train
data.frame
structure(list(x = c(-49.2180036048647, -49.588646107472, -49.4994660957961,
-49.409070720487, -49.5901102247847, -49.408915914575), y = c(-28.8051270000448,
-28.7079195821462, -28.7107590910968, -28.7091665158844, -28.6199868803577,
-28.6218794939721), ua = c("ua_35", "ua_39", "ua_40", "ua_41",
"ua_47", "ua_49"), occ = structure(c(1L, 1L, 1L, 1L, 1L, 1L), levels = c("C0",
"C1"), class = "factor"), PC1 = c(5.45050585867435, 0.971417276490495,
3.04696429464962, 3.49333347532713, -2.1314970593002, 1.60231066244416
), PC2 = c(1.62129971834298, -2.67253316161164, 0.803381999088846,
1.24449786054891, -6.62041787415885, -1.15464748692714), PC3 = c(0.677239125000311,
-0.800550473360275, -0.666475036424968, -0.386198549623231, -0.197769597835757,
-0.445143448591713), PC4 = c(-4.01008804477917, 1.84301040539535,
0.967638087266157, 0.0781875925367184, 0.994999464193385, 1.58963654917174
), PC5 = c(0.785837462504693, 0.0665561890147296, -0.72701888727977,
-0.739597425424334, 0.712329685720884, -0.351229249996707), block = c(1L,
1L, 1L, 1L, 1L, 1L)), row.names = c(10L, 12L, 13L, 14L, 15L,
16L), class = "data.frame")
There are no NAs in my data, I double-checked and also ran previous models with the same data. The issue is only with method = ''bartMachine''