Thursday, 8 August 2013

finding support vector caret test

finding support vector caret test

i want to find specific support vectors from the training data. i have
build the model using 'caret' package 'train' method. the code is below.
library(caret)
trainset <- data.frame(
weight=c(150, 163, 170, 100, 151, 180, 140, 140, 190),
height=c(60, 65, 67, 62, 63, 72, 55, 56, 75))
testset <- data.frame(
weight=factor(100, 120, 110),
height=c(56, 65, 60))
library(kernlab)
set.seed(231)
finding optimal value of a tuning parameter
sigDist <- sigest(height ~ ., data = trainset, frac = 1)
creating a grid of two tuning parameters, .sigma comes from the earlier
line. we are trying to find best value of .C
svmTuneGrid <- data.frame(.sigma = sigDist[1], .C = 2^(-2:7))
set.seed(1056)
svmFit <- train(height ~ .,
data = trainset,
method = "svmRadial",
preProc = c("center", "scale"),
tuneGrid = svmTuneGrid,
trControl = trainControl(method = "repeatedcv", number=2,
repeats = 2))
svmFit
svmFit$finalModel
final line gives output as below. it says that there are 5 support
vecttors. How can i find out of 9 training data set points 5 support
vectors?
thanks
svmFit$finalModel
Support Vector Machine object of class "ksvm"
SV type: eps-svr (regression) parameter : epsilon = 0.1 cost C = 8
Gaussian Radial Basis kernel function. Hyperparameter : sigma =
0.192151074780503
Number of Support Vectors : 5
Objective Function Value : -8.5941 Training error : 0.039607

No comments:

Post a Comment