Predict new test set using wsvm function and compute error rate

Description

Predict a weighted svm fit and compute error rate.

Usage

1
    wsvm.predict(X, Y, new.X, new.Y, model, comp.error.rate = FALSE)

Arguments

X

input variable matrix to generate kernel. Data type must be a matrix format.

Y

output variable vector which will be declared as a matrix in SVM. Data type must be a matrix format.

new.X

test predictors.

new.Y

test response.

model

predicted model including alpha and bias terms. The alpha means estimated coefficients(nrow(X) by 1) and bias means bias term.

comp.error.rate

logical value. If true, calculate error rate.

Details

Predict a weighted svm fit.

Value

A function wsvm.predict generates a list consists of values, g, and error.rate.

predicted.values

fitted value at new.X

g

signs of predicted values

error.rate

misclassification error rate

Author(s)

SungWhan Kim swiss747@korea.ac.kr
Soo-Heang Eo hanansh@korea.ac.kr

See Also

wsvm, wsvm.boost

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# generate a simulation data set using mixture example(page 17, Friedman et al. 2000)

svm.data <- simul.wsvm(set.seeds = 123)
X <- svm.data$X
Y <- svm.data$Y
new.X <- svm.data$new.X
new.Y <- svm.data$new.Y

# run Weighted K-means clustering SVM with boosting algorithm
model <- wsvm(X, Y, c.n = rep(1/ length(Y),length(Y)))

# predict the model and compute an error rate. 
pred <- wsvm.predict(X,Y, new.X, new.Y, model)

Error.rate(pred$predicted.Y, Y)

# add boost algorithm

boo <- wsvm.boost(X, Y, new.X, new.Y, c.n = rep(1/ length(Y),length(Y)), 
    B = 50, kernel.type = list(type = "rbf", par= 0.5), C = 4, 
    eps = 1e-10, plotting = TRUE)
boo