cv.dcsvm | R Documentation |
Performs cross-validation for the sparse density-convoluted SVM to estimate the optimal tuning parameter lambda
.
cv.dcsvm(x, y, lambda = NULL, hval = 1,
pred.loss = c("misclass", "loss"), nfolds = 5, foldid, ...)
x |
A matrix of predictors, i.e., the |
y |
A vector of binary class labels, i.e., the |
lambda |
Default is |
hval |
The bandwidth parameter for kernel smoothing. Default is 1. |
pred.loss |
|
nfolds |
The number of folds. Default is 5. The allowable range is from 3 to the sample size. Larger |
foldid |
An optional vector with values between 1 and |
... |
Other arguments that can be passed to |
Cross-Validation for Sparse Density-Convoluted SVM
Conducts a k-fold cross-validation for dcsvm
and returns the suggested values of the L1 parameter lambda
.
This function runs dcsvm
on the sparse density-convoluted SVM by excluding each fold in turn, then computes the mean cross-validation error and standard deviation. It is adapted from the cv
functions in the gcdnet
and glmnet
packages.
A cv.dcsvm
object is returned, which includes the cross-validation fit:
lambda |
The |
cvm |
A vector of length |
cvsd |
A vector of length |
cvupper |
The upper curve: |
cvlower |
The lower curve: |
nzero |
Number of non-zero coefficients at each |
name |
"Mis-classification error", for plotting purposes. |
dcsvm.fit |
A fitted |
lambda.min |
The |
lambda.1se |
The largest value of |
cv.min |
The minimum cross-validation error. |
cv.1se |
The cross-validation error associated with |
dcsvm
, plot.cv.dcsvm
, predict.cv.dcsvm
, and coef.cv.dcsvm
methods.
data(colon)
colon$x <- colon$x[ ,1:100] # Use only the first 100 columns for this example
n <- nrow(colon$x)
set.seed(1)
id <- sample(n, trunc(n / 3))
cvfit <- cv.dcsvm(colon$x[-id, ], colon$y[-id], lam2=1, nfolds=5)
plot(cvfit)
predict(cvfit, newx=colon$x[id, ], s="lambda.min")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.