
Last chance! 50% off unlimited learning
Sale ends in
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)
design matrix, matrix of size
classes, factor of length
sample weights, a vector of length
grouping of features (covariates), a vector of length
the group weights, a vector of length groupWeights = NULL
default weights will be used.
Default weights are 0 for the intercept and
a matrix of size parameterWeights = NULL
default weights will be used.
Default weights are is 0 for the intercept weights and 1 for all other weights.#'
the
if TRUE the features are standardize before fitting the model. The model parameters are returned in the original scale.
lambda.min relative to lambda.max or the lambda sequence for the regularization path.
length of lambda sequence (ignored if length(lambda) > 1
)
the fold of the cross validation, an integer larger than cv.indices != NULL
.
If fold
max(table(classes))
then the data will be split into fold
disjoint subsets keeping the ration of classes approximately equal.
Otherwise the data will be split into fold
disjoint subsets without keeping the ration fixed.
a list of indices of a cross validation splitting.
If cv.indices = NULL
then a random splitting will be generated using the fold
argument.
should the model include intercept parameters
if TRUE x
will be treated as sparse, if x
is a sparse matrix it will be treated as sparse by default.
Deprecated (will be removed in 2018),
instead use use_parallel = TRUE
and registre parallel backend (see package 'doParallel').
The maximal number of threads to be used.
If TRUE
the foreach
loop will use %dopar%
. The user must registre the parallel backend.
the algorithm configuration to be used.
the linear predictors -- a list of length length(lambda)
one item for each lambda value, with each item a matrix of size
the estimated probabilities - a list of length length(lambda)
one item for each lambda value, with each item a matrix of size
the estimated classes - a matrix of size length(lambda)
.
the cross validation splitting used.
number of features used in the models.
number of parameters used in the models.
the true classes used for estimation, this is equal to the classes
argument
# NOT RUN {
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")
# }
Run the code above in your browser using DataLab