predict.sparseSVM {sparseSVM} | R Documentation |
Model predictions based on "sparseSVM" object.
Description
This function returns fitted values, coefficients and more from a fitted "sparseSVM"
object.
Usage
## S3 method for class 'sparseSVM'
predict(object, X, lambda, type = c("class","coefficients","nvars"),
exact = FALSE, ...)
## S3 method for class 'sparseSVM'
coef(object, lambda, exact = FALSE, ...)
Arguments
object |
Fitted |
X |
Matrix of values at which predictions are to be made. Used only for |
lambda |
Values of the regularization parameter |
type |
Type of prediction. |
exact |
If |
... |
Not used. Other arguments to predict. |
Value
The object returned depends on type.
Author(s)
Congrui Yi and Yaohui Zeng
Maintainer: Congrui Yi <eric.ycr@gmail.com>
See Also
Examples
X = matrix(rnorm(1000*100), 1000, 100)
b = 3
w = 5*rnorm(10)
eps = rnorm(1000)
y = sign(b + drop(X[,1:10] %*% w + eps))
fit = sparseSVM(X, y)
predict(fit, X[1:5,], lambda = c(0.05, 0.03))
predict(fit, X[1:5,], lambda = 0.05, exact = TRUE)
predict(fit, type = "nvars")
coef(fit, lambda = 0.05)