predict.ksvm {kernlab} | R Documentation |
Prediction of test data using support vector machines
## S4 method for signature 'ksvm': predict(object, newdata, type = "response", coupler = "minpair")
object |
an S4 object of class ksvm created by the
ksvm function |
newdata |
a data frame or matrix containing new data |
type |
one of response , probabilities ,votes
indicating the type of output: predicted values, matrix of class
probabilities, or matrix of vote counts. |
coupler |
Coupling method used in the multiclass case, can be one
of minpair or pkpd (see reference for more details). |
If type(object)
is C-classification
,
nu-classification
or spoc-classification
the vector returned depends on the argument type
:
response |
predicted classes (the classes with majority vote). |
probabilities |
matrix of class probabilities (one column for each class and one row for each input). |
votes |
matrix of vote counts (one column for each class and one row for each new input) |
If type(object)
is eps-regression
,or
nu-regression
a vector of predicted values is returned.
If type(object)
is one-classification
a vector of
logical values is returned.
Alexandros Karatzoglou
alexandros.karatzoglou@ci.tuwien.ac.at
## 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,prob.model=TRUE) filter ## predict mail type probabilities on the test set mailtype <- predict(filter,spamtest,type="probabilities") mailtype[c(1:10,1000:1010),]