## Not run:
#
# ######
# ## Using in the context of an experiment
#
#
# data(algae,package="DMwR")
# library(e1071)
#
# ## This will issue several warnings because this implementation of SVMs
# ## will ignore test cases with NAs in some predictor. Our infra-structure
# ## issues a warning and fills in these with the prediction of an NA
# res <- performanceEstimation(
# PredTask(a1 ~ .,algae[,1:12],"alga1"),
# Workflow(learner="svm"),
# EstimationTask(metrics="mse")
# )
# summary(getIterationPreds(res,1,1,it=1))
#
# ## one way of overcoming this would be to post-process the NA
# ## predictions into a statistic of centrality
# resN <- performanceEstimation(
# PredTask(a1 ~ .,algae[,1:12],"alga1"),
# Workflow(learner="svm",post="na2central"),
# EstimationTask(metrics="mse")
# )
# summary(getIterationPreds(resN,1,1,it=1))
#
# ## because the SVM also predicts negative values which does not make
# ## sense in this application (the target are frequencies thus >= 0) we
# ## could also include some further post-processing to take care of
# ## negative predictions
# resN <- performanceEstimation(
# PredTask(a1 ~ .,algae[,1:12],"alga1"),
# Workflow(learner="svm",post=c("na2central","onlyPos")),
# EstimationTask(metrics="mse")
# )
# summary(getIterationPreds(resN,1,1,it=1))
#
# ######################
# ## An example with utility maximization learning for the
# ## BreastCancer data set on package mlbench
# ##
# data(BreastCancer,package="mlbench")
#
# ## First lets create the cost-benefit matrix
# cb <- matrix(c(1,-10,-100,100),byrow=TRUE,ncol=2)
# colnames(cb) <- paste("p",levels(BreastCancer$Class),sep=".")
# rownames(cb) <- paste("t",levels(BreastCancer$Class),sep=".")
#
# ## This leads to the following cost-benefit matrix
# ## p.benign p.malignant
# ## t.benign 1 -10
# ## t.malignant -100 100
#
# ## Now the performance estimation. We are estimating error rate (wrong
# ## for cost sensitive tasks!) and total utility of the model predictions
# ## (the right thing to do here!)
# library(rpart)
#
# r <- performanceEstimation(
# PredTask(Class ~ .,BreastCancer[,-1],"breastCancer"),
# c(Workflow(wfID="rpart.cost",
# learner="rpart",
# post="maxutil",
# post.pars=list(cb.matrix=cb)
# ),
# Workflow(wfID="rpart",
# learner="rpart",
# predictor.pars=list(type="class")
# )
# ),
# EstimationTask(
# metrics=c("err","totU"),
# evaluator.pars=list(benMtrx=cb,posClass="malignant"),
# method=CV(strat=TRUE)))
#
# ## Analysing the results
# rankWorkflows(r,maxs=c(FALSE,TRUE))
#
# ## Visualizing them
# plot(r)
#
# ## End(Not run)
Run the code above in your browser using DataLab