I am creating a CART model and I am trying to configure 2 rpart parameters - CP and Maxdepth. Although Caret works well for one parameter at a time when both are used, it continues to throw an error, and I cannot understand why
library(caret)
data(iris)
tc <- trainControl("cv",10)
rpart.grid <- expand.grid(cp=seq(0,0.1,0.01), minsplit=c(10,20))
train(Petal.Width ~ Petal.Length + Sepal.Width + Sepal.Length, data=iris, method="rpart",
trControl=tc, tuneGrid=rpart.grid)
I get the following error:
Error in train.default(x, y, weights = w, ...) :
The tuning parameter grid should have columns cp
source
share