## simple example using the spam data set
data(spam)
## create test and training set
spamtrain <- spam[1:(2 * dim(spam)[1]/3), ]
spamtest <- spam[((2 * dim(spam)[1]/3) + 1):length(spam), ]
## train a support vector machine
filter <- ksvm(type~.,data=spamtrain,kernel="rbfdot",kpar=list(sigma=0.05),C=5,cross=3)
filter
# the kernel function
kernelf(filter)
# the alpha values
alpha(filter)
# the coefficients
coeff(filter)
# the fitted values
fit(filter)
# the cross validation error
cross(filter)
Run the code above in your browser using DataLab