Description Usage Arguments Value Note Author(s) See Also Examples
This function predicts values based upon a model trained by wsvm
.
1 2 3 
object 
Object of class 
newdata 
An object containing the new input data: either a
matrix or a sparse matrix (object of class

decision.values 
Logical controlling whether the decision values of all binary classifiers computed in multiclass classification shall be computed and returned. 
probability 
Logical indicating whether class probabilities
should be computed and returned. Only possible if the model was
fitted with the 
na.action 
A function to specify the action to be taken if ‘NA’s are
found. The default action is 
... 
Currently not used. 
A vector of predicted values (for classification: a vector of labels, for density
estimation: a logical vector). If decision.value
is
TRUE
, the vector gets a "decision.values"
attribute
containing a n x c matrix (n number of predicted values, c number of
classifiers) of all c binary classifiers' decision values. There are k
* (k  1) / 2 classifiers (k number of classes). The colnames of
the matrix indicate the labels of the two classes. If probability
is
TRUE
, the vector gets a "probabilities"
attribute
containing a n x k matrix (n number of predicted values, k number of
classes) of the class probabilities.
If the training set was scaled by wsvm
(done by default), the
new data is scaled accordingly using scale and center of
the training data.
David Meyer (based on C/C++code by ChihChung Chang and ChihJen Lin)
Modified by Tianchen Xu tx2155@columbia.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41  ## load dataset
data(iris)
attach(iris)
## classification mode
# default with factor response:
model1 < wsvm(Species ~ ., weight = rep(1,150), data = iris) # same weights
model2 < wsvm(x = iris[,1:4], y = iris[,5],
weight = c(rep(0.08, 50),rep(1,100))) # less weights to setosa
x < subset(iris, select = Species)
y < iris$Species
model3 < wsvm(x, y, weight = rep(10,150)) # similar to model 1, but larger weights for all subjects
# test with train data
pred < predict(model1, iris[,1:4])
# (same as:)
pred < fitted(model1)
# Check accuracy:
table(pred, y) # model 1, equal weights
# compute decision values and probabilities:
pred < predict(model1, x, decision.values = TRUE)
attr(pred, "decision.values")[1:4,]
## try regression mode on two dimensions
# create data
x < seq(0.1, 5, by = 0.05)
y < log(x) + rnorm(x, sd = 0.2)
# estimate model and predict input values
model1 < wsvm(x, y, weight = rep(1,99))
model2 < wsvm(x, y,
weight = seq(99,1,length.out = 99)) # decreasing weights
# visualize
plot(x, y)
points(x, log(x), col = 2)
points(x, fitted(model1), col = 4)
points(x, fitted(model2), col = 3) # better fit for the first few points

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.