## Not run:
# data(iris)
# library(e1071)
#
# ## a standard workflow using and SVM with default parameters
# w.s <- Workflow(wfID="std.svm",learner="svm")
# w.s
#
# irisExp <- performanceEstimation(
# PredTask(Species ~ .,iris),
# w.s,
# EstimationTask("acc"))
#
# getIterationsPreds(irisExp,1,1,it=4)
# getIterationsInfo(irisExp,1,1,rep=1,fold=2)
#
# ## A more sophisticated standardWF
# ## - as pre-processing we imput NAs with either the median (numeric
# ## features) or the mode (nominal features); and we also scale
# ## (normalize) the numeric predictors
# ## - as learning algorithm we use and SVM with cost=10 and gamma=0.01
# ## - as post-processing we scale all predictions into the range [0..50]
# w.s2 <- Workflow(pre=c("centralImp","scale"),
# learner="svm",
# learner.pars=list(cost=10,gamma=0.01),
# post="cast2int",
# post.pars=list(infLim=0,supLim=50),
# .fullOutput=TRUE
# )
#
# data(algae,package="DMwR")
#
# a1.res <- performanceEstimation(
# PredTask(a1 ~ ., algae[,1:12],"alga1"),
# w.s2,
# EstimationTask("mse")
# )
#
# ## Workflow variants of a standard workflow
# ws <- workflowVariants(
# pre=c("centralImp","scale"),
# learner="svm",
# learner.pars=list(cost=c(1,5,10),gamma=0.01),
# post="cast2int",
# post.pars=list(infLim=0,supLim=c(10,50,80)),
# .fullOutput=TRUE,
# as.is="pre"
# )
# a1.res <- performanceEstimation(
# PredTask(a1 ~ ., algae[,1:12],"alga1"),
# ws,
# EstimationTask("mse")
# )
#
# ## An example using GBM that is a bit different in terms of the
# ## prediction part as it requires to select the number of trees of the
# ## ensemble to use
# data(Boston, package="MASS")
# library(gbm)
#
# ## A user written predict function to allow for using the standard
# ## workflows
# gbm.predict <- function(model, test, method, ...) {
# best <- gbm.perf(model, plot.it=FALSE, method=method)
# return(predict(model, test, n.trees=best, ...))
# }
#
# resG <- performanceEstimation(
# PredTask(medv ~.,Boston),
# Workflow(learner="gbm",
# learner.pars=list(n.trees=1000, cv.folds=10),
# predictor="gbm.predict",
# predictor.pars=list(method="cv")),
# EstimationTask(metrics="mse",method=CV())
# )
#
# ## End(Not run)
Run the code above in your browser using DataLab