## example using the spam data set
data(spam)
## create test and training set
traindex <- sample(1:dim(spam)[1],2*dim(spam)[1]/3)
spamtrain <- spam[traindex, ]
spamtest <- spam[-traindex, ]
## train a support vector machine
filter <- ksvm(type~.,data=spamtrain,kernel="rbfdot",kpar=list(sigma=0.05),C=5,cross=3)
filter
## predict mail type probabilities on the test set
mailtype <- predict(filter,spamtest,type="probabilities")
mailtype[c(1:10,1000:1010),]
Run the code above in your browser using DataLab