predict.cv.sparseSVM: Model predictions based on "cv.sparseSVM" object.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/predict.cv.sparseSVM.R

Description

This function returns fitted values, coefficients and more from a fitted "cv.sparseSVM" object.

Usage

1
2
3
4
5
## S3 method for class 'cv.sparseSVM'
predict(object, X, lambda = object$lambda.min, 
        type = c("class","coefficients","nvars"), exact = FALSE, ...)
## S3 method for class 'cv.sparseSVM'
coef(object, lambda = object$lambda.min, exact = FALSE, ...)

Arguments

object

Fitted "cv.sparseSVM" model object.

X

Matrix of values at which predictions are to be made. Used only for type = "class".

lambda

Values of the regularization parameter lambda at which predictions are requested. Default is the one corresponding to the minimum cross-validation error.

type

Type of prediction. "class" returns the class labels; "coefficients" returns the coefficients; "nvars" returns the number of nonzero coefficients at each value of lambda.

exact

If exact=FALSE (default), then the function uses linear interpolation to make predictions for values of lambda that do not coincide with those used to fit the model. If exact=TRUE, and predictions are requested at values of lambda not included in the original fit, the model is refit on a lambda sequence consisting object$lambda and the new ones before predictions are made.

...

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

sparseSVM, cv.sparseSVM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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))

cv.fit <- cv.sparseSVM(X, y, ncores = 2, seed = 1234)
predict(cv.fit, X)
predict(cv.fit, type = 'nvars')
predict(cv.fit, type = 'coef')
coef(cv.fit)

sparseSVM documentation built on May 2, 2019, 11:02 a.m.