predict.cv.dcsvm: Make Predictions from a "cv.dcsvm" Object

View source: R/cv.dcsvm.R

predict.cv.dcsvmR Documentation

Make Predictions from a "cv.dcsvm" Object

Description

Predicts class labels for new data based on the cross-validated lambda values from a cv.dcsvm object.

Usage

## S3 method for class 'cv.dcsvm'
predict(object, newx, s = c("lambda.1se", "lambda.min"), ...)

Arguments

object

A fitted cv.dcsvm object.

newx

A matrix of new values for x at which predictions are to be made. Must be a matrix. See documentation for predict.dcsvm.

s

Value(s) of the L1 tuning parameter lambda for making predictions. Default is s = "lambda.1se" saved in the cv.dcsvm object. An alternative choice is s = "lambda.min". s can also be numeric, representing the specific value(s) to use.

...

Not used. Other arguments to predict.

Details

Make Predictions from a "cv.dcsvm" Object

This function predicts the class labels of new observations using the sparse density-convoluted SVM at the lambda values suggested by cv.dcsvm.

This function uses the cross-validation results to make predictions. It is adapted from the predict.cv function in the glmnet and gcdnet packages.

Value

Predicted class labels or fitted values, depending on the choice of s and any arguments passed to the dcsvm method.

See Also

cv.dcsvm, and coef.cv.dcsvm methods.

Examples

data(colon)
colon$x <- colon$x[ , 1:100] # Use only the first 100 columns for this example
set.seed(1)
cv <- cv.dcsvm(colon$x, colon$y, lam2=1, nfolds=5)
predict(cv$dcsvm.fit, newx=colon$x[2:5, ], 
  s=cv$lambda.1se, type="class")


dcsvm documentation built on April 3, 2025, 10:27 p.m.