## Not run:
# ## Estimating MSE for 3 variants of both
# ## regression trees and SVMs, on two data sets, using one repetition
# ## of 10-fold CV
# library(e1071)
# library(DMwR)
# data(swiss)
# data(mtcars)
#
# ## Estimating MSE using 10-fold CV for 4 variants of a standard workflow
# ## using an SVM as base learner and 3 variants of a regression tree.
# res <- performanceEstimation(
# c(PredTask(Infant.Mortality ~ .,swiss),PredTask(mpg ~ ., mtcars)),
# c(workflowVariants(learner="svm",
# learner.pars=list(cost=c(1,10),gamma=c(0.01,0.5))),
# workflowVariants(learner="rpartXse",
# learner.pars=list(se=c(0,0.5,1)))
# ),
# EstimationTask(metrics="mse")
# )
#
# ## Check a summary of the results
# summary(res)
#
# ## best performers for each metric and task
# topPerformers(res)
#
#
# ## Estimating the accuracy of a default SVM on IRIS using 10 repetitions
# ## of a 80%-20% Holdout
# data(iris)
# res1 <- performanceEstimation(PredTask(Species ~ .,iris),
# Workflow(learner="svm"),
# EstimationTask(metrics="acc",method=Holdout(nReps=10,hldSz=0.2)))
# summary(res1)
#
# ## Now an example with a user-defined workflow
# myWF <- function(form,train,test,wL=0.5,...) {
# require(rpart,quietly=TRUE)
# ml <- lm(form,train)
# mr <- rpart(form,train)
# pl <- predict(ml,test)
# pr <- predict(mr,test)
# ps <- wL*pl+(1-wL)*pr
# list(trues=responseValues(form,test),preds=ps)
# }
# resmywf <- performanceEstimation(
# PredTask(mpg ~ ., mtcars),
# workflowVariants(wf="myWF",wL=seq(0,1,by=0.1)),
# EstimationTask(metrics="mae",method=Bootstrap(nReps=50))
# )
# summary(resmywf)
#
# ## End(Not run)
Run the code above in your browser using DataLab