Thanks to Zach's code.
I run R code as below and get error that cold not find "trainControl and train function"
#Use the same CV-folds for each model require(caret) myControl <- trainControl(method='cv', number=10, index=createFolds(y, k=10)) #Fit models model_rpart <- train(X, y, method='rpart', trControl=myControl) model_ctree <- train(X, y, method='ctree', trControl=myControl) model_rf <- train(X, y, method='rf', trControl=myControl)
Would you give me some suggestion since I am a R beginner. Thank you.