Consider the following code:
请考虑以下代码:
#Load Data
set.seed(42)
require(mlbench)
data(BostonHousing)
y <- BostonHousing[,14]
X <- BostonHousing[,1:13]
#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)
#Plot
resamples <- resamples(list(
rpart=model_rpart,
ctree=model_ctree,
model_rf=model_rf
))
dotplot(resamples, metric='RMSE')
#Load