## load transcription factor binding site data
data(TFBS)
enhancerFB
## The C-svc implementation from LiblineaR is chosen for most of the
## examples because it is the fastest SVM. With SVMs from other packages
## slightly better results could be achievable. Because of the higher
## runtime needed for nested cross validation please run the examples
## below manually. All samples of the data set are used in the examples.
train <- sample(1:length(enhancerFB), length(enhancerFB))
## model selection with single kernel object and multiple
## hyperparameter values, 5 fold inner CV and 3 fold outer CV
## create gappy pair kernel with normalization
gappyK1M3 <- gappyPairKernel(k=1, m=3)
## show details of single gappy pair kernel object
gappyK1M3
pkg <- "LiblineaR"
svm <- "C-svc"
cost <- c(50,100,150,200,250,300)
model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=gappyK1M3,
pkg=pkg, svm=svm, cost=cost, explicit="yes", cross=3,
nestedCross=2, showProgress=TRUE)
## show best parameter settings
modelSelResult(model)
## show model selection result which is the result of the outer CV
cvResult(model)
## Not run:
# ## repeated model selection
# pkg <- "LiblineaR"
# svm <- "C-svc"
# cost <- c(50,100,150,200,250,300)
# model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=gappyK1M3,
# pkg=pkg, svm=svm, cost=cost, explicit="yes", cross=10,
# nestedCross=3, noNestedCross=3, showProgress=TRUE)
#
# ## show best parameter settings
# modelSelResult(model)
#
# ## show model selection result which is the result of the outer CV
# cvResult(model)
#
# ## plot CV result
# plot(cvResult(model))
# ## End(Not run)
Run the code above in your browser using DataLab