cv | R Documentation |
Multinomial sparse group lasso cross validation, with or without parallel backend.
cv(x, classes, sampleWeights = NULL, grouping = NULL,
groupWeights = NULL, parameterWeights = NULL, alpha = 0.5,
standardize = TRUE, lambda, d = 100, fold = 10L,
cv.indices = list(), intercept = TRUE, sparse.data = is(x,
"sparseMatrix"), max.threads = NULL, use_parallel = FALSE,
algorithm.config = msgl.standard.config)
x |
design matrix, matrix of size |
classes |
classes, factor of length |
sampleWeights |
sample weights, a vector of length |
grouping |
grouping of features (covariates), a vector of length |
groupWeights |
the group weights, a vector of length
for all other weights. |
parameterWeights |
a matrix of size |
alpha |
the |
standardize |
if TRUE the features are standardize before fitting the model. The model parameters are returned in the original scale. |
lambda |
lambda.min relative to lambda.max or the lambda sequence for the regularization path. |
d |
length of lambda sequence (ignored if |
fold |
the fold of the cross validation, an integer larger than |
cv.indices |
a list of indices of a cross validation splitting.
If |
intercept |
should the model include intercept parameters |
sparse.data |
if TRUE |
max.threads |
Deprecated (will be removed in 2018),
instead use |
use_parallel |
If |
algorithm.config |
the algorithm configuration to be used. |
link |
the linear predictors – a list of length |
response |
the estimated probabilities - a list of length |
classes |
the estimated classes - a matrix of size |
cv.indices |
the cross validation splitting used. |
features |
number of features used in the models. |
parameters |
number of parameters used in the models. |
classes.true |
the true classes used for estimation, this is equal to the |
Martin Vincent
data(SimData)
# A quick look at the data
dim(x)
table(classes)
# Setup clusters
cl <- makeCluster(2)
registerDoParallel(cl)
# Run cross validation using 2 clusters
# Using a lambda sequence ranging from the maximal lambda to 0.7 * maximal lambda
fit.cv <- msgl::cv(x, classes, alpha = 0.5, lambda = 0.7, use_parallel = TRUE)
# Stop clusters
stopCluster(cl)
# Print some information
fit.cv
# Cross validation errors (estimated expected generalization error)
# Misclassification rate
Err(fit.cv)
# Negative log likelihood error
Err(fit.cv, type="loglike")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.