## Estimating the mean absolute error and the normalized mean squared
## error of rpart on the swiss data, using one repetition of 10-fold CV
data(swiss)
## First the user defined function (note: can have any name)
cv.rpart <- function(form, train, test, ...) {
require(rpart)
model <- rpart(form, train, ...)
preds <- predict(model, test)
regr.eval(resp(form, test), preds,
stats=c('mae','nmse'), train.y=resp(form, train))
}
## Now the evaluation
eval.res <- crossValidation(learner('cv.rpart',pars=list()),
dataset(Infant.Mortality ~ ., swiss),
cvSettings(1,10,1234))
## Check a summary of the results
summary(eval.res)
## Plot them
## Not run:
# plot(eval.res)
# ## End(Not run)
Run the code above in your browser using DataLab