I am building a CART model and I am trying to tune 2 parameters of rpart - CP and Maxdepth. While the Caret package is working well for one parameter at a time, when both are used it keeps throwing an error and i am not able to figure out why
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",
Error in train.default(x, y, weights = w, ...) :
The tuning parameter grid should have columns cp
Method "rpart" is only capable of tuning the cp, method "rpart2" is used for maxdepth. There is no tuning for minsplit or any of the other rpart controls. If you want to tune on different options you can write a custom model to take this into account.