## set seed for random generator, included here only to make results
## reproducable for this example
set.seed(456)
## load transcription factor binding site data
data(TFBS)
enhancerFB
## select 70\% of the samples for training and the rest for test
train <- sample(1:length(enhancerFB), length(enhancerFB) * 0.7)
test <- c(1:length(enhancerFB))[-train]
## create the kernel object for gappy pair kernel with normalization
gappy <- gappyPairKernel(k=1, m=3)
## show details of kernel object
gappy
## run training with explicit representation
model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=gappy,
pkg="LiblineaR", svm="C-svc", cost=80, explicit="yes",
featureWeights="no")
## predict the test sequences
pred <- predict(model, enhancerFB[test])
## print prediction performance
evaluatePrediction(pred, yFB[test], allLabels=unique(yFB))
## print prediction performance including AUC
## additionally determine decision values
preddec <- predict(model, enhancerFB[test], predictionType="decision")
evaluatePrediction(pred, yFB[test], allLabels=unique(yFB),
decValues=preddec)
## print prediction performance including training set balance
trainPosNeg <- c(length(which(yFB[train] == 1)),
length(which(yFB[train] == -1)))
evaluatePrediction(pred, yFB[test], allLabels=unique(yFB),
numPosNegTrainSamples=trainPosNeg)
## or get prediction performance as data frame
perf <- evaluatePrediction(pred, yFB[test], allLabels=unique(yFB),
print=FALSE)
## show performance values in data frame
perf
Run the code above in your browser using DataLab