Learn R Programming

svmpath (version 0.970)

predict.svmpath: Make predictions from a "svmpath" object

Description

Provide a value for lambda, and produce the fitted lagrange alpha values. Provide values for x, and get fitted function values or class labels.

Usage

# S3 method for svmpath
predict(object, newx, lambda, type = c("function", "class",
"alpha", "margin"),...)

Arguments

object

fitted svmpath object

newx

values of x at which prediction are wanted. This is a matrix with observations per row

lambda

the value of the regularization parameter. Note that lambda is equivalent to 1/C for the usual parametrization of a SVM

type

type of prediction, with default "function". For type="alpha" or type="margin" the newx argument is not required

...

Generic compatibility

Value

In each case, the desired prediction.

Details

This implementation of the SVM uses a parameterization that is slightly different but equivalent to the usual (Vapnik) SVM. Here \(\lambda=1/C\). The Lagrange multipliers are related via \(\alpha^*_i=\alpha_i/\lambda\), where \(\alpha^*_i\) is the usual multiplier, and \(\alpha_i\) our multiplier. Note that if alpha=0, that observation is right of the elbow; alpha=1, left of the elbow; 0<alpha<1 on the elbow. The latter two cases are all support points.

References

The paper http://www-stat.stanford.edu/~hastie/Papers/svmpath.pdf, as well as the talk http://www-stat.stanford.edu/~hastie/TALKS/svmpathtalk.pdf.

See Also

coef.svmpath, svmpath

Examples

Run this code
# NOT RUN {
data(svmpath)
attach(balanced.overlap)
fit <- svmpath(x,y,trace=TRUE,plot=TRUE)
predict(fit, lambda=1,type="alpha")
predict(fit, x, lambda=.9)
detach(2)
# }

Run the code above in your browser using DataLab