## Not run: 
# 
# ## Estimating the mean absolute error and the normalized mean squared
# ## error of rpart on the swiss data, using 70%-30% hold-out
# library(e1071)
# data(swiss)
# 
# ## Now the evaluation
# eval.res <- hldEstimates(
#              Workflow(wf="standardWF",wfID="svmApproach",
#                       learner="svm",learner.pars=list(cost=10,gamma=0.1)
#                      ),
#              PredTask(Infant.Mortality ~ ., swiss),
#              EstimationTask(metrics=c("mae","nmse"),
#                             method=Holdout(nReps=5,hldSz=0.3))
#                         )
# 
# ## Check a summary of the results
# summary(eval.res)
# 
# ## An example with a user-defined workflow function implementing a
# ## simple approach using linear regression models but also containing
# ## some data-preprocessing and well as results post-processing.
# myLM <- function(form,train,test,k=10,.outModel=FALSE) {
#     require(DMwR)
#     ## fill-in NAs on both the train and test sets
#     ntr <- knnImputation(train,k)
#     nts <- knnImputation(test,k,distData=train)
#     ## obtain a linear regression model and simplify it
#     md <- lm(form,ntr)
#     md <- step(md)
#     ## get the model predictions
#     p <- predict(md,nts)
#     ## post-process the predictions (this is an example assuming the target
#     ## variable is always positive so we change negative predictions into 0)
#     p <- ifelse(p < 0,0,p)
#     ## now get the final return object
#     res <- list(trues=responseValues(form,nts), preds=p)
#     if (.outModel) res <- c(res,list(model=m))
#     res
# }
# 
# ## Now for the Holdout estimation 
# data(algae,package="DMwR")
# eval.res2 <- hldEstimates(
#              Workflow(wf="myLM",k=5),
#              PredTask(a1 ~ ., algae[,1:12],"alga1"),
#              EstimationTask("mse",method=Holdout(nReps=5)))
# 
# ## Check a summary of the results
# summary(eval.res2)
# ## End(Not run)
Run the code above in your browser using DataLab