Skip to contents

Generalized linear models with elastic net regularization. Calls glmnet::cv.glmnet() from package glmnet.

The default for hyperparameter family is set to "binomial" or "multinomial", depending on the number of classes.

Dictionary

This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():

mlr_learners$get("classif.cv_glmnet")
lrn("classif.cv_glmnet")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “logical”, “integer”, “numeric”

  • Required Packages: mlr3, mlr3learners, glmnet

Parameters

IdTypeDefaultLevelsRange
alignmentcharacterlambdalambda, fraction-
alphanumeric1\([0, 1]\)
bignumeric9.9e+35\((-\infty, \infty)\)
devmaxnumeric0.999\([0, 1]\)
dfmaxinteger-\([0, \infty)\)
epsnrnumeric1e-08\([0, 1]\)
epsnumeric1e-06\([0, 1]\)
excludeinteger-\([1, \infty)\)
exmxnumeric250\((-\infty, \infty)\)
fdevnumeric1e-05\([0, 1]\)
foldiduntyped-
gammauntyped--
groupedlogicalTRUETRUE, FALSE-
interceptlogicalTRUETRUE, FALSE-
keeplogicalFALSETRUE, FALSE-
lambda.min.rationumeric-\([0, 1]\)
lambdauntyped--
lower.limitsuntyped--
maxitinteger100000\([1, \infty)\)
mnlaminteger5\([1, \infty)\)
mxitnrinteger25\([1, \infty)\)
mxitinteger100\([1, \infty)\)
nfoldsinteger10\([3, \infty)\)
nlambdainteger100\([1, \infty)\)
offsetuntyped-
parallellogicalFALSETRUE, FALSE-
penalty.factoruntyped--
pmaxinteger-\([0, \infty)\)
pminnumeric1e-09\([0, 1]\)
precnumeric1e-10\((-\infty, \infty)\)
predict.gammanumericgamma.1se\((-\infty, \infty)\)
relaxlogicalFALSETRUE, FALSE-
snumericlambda.1se\([0, \infty)\)
standardizelogicalTRUETRUE, FALSE-
standardize.responselogicalFALSETRUE, FALSE-
threshnumeric1e-07\([0, \infty)\)
trace.itinteger0\([0, 1]\)
type.gaussiancharacter-covariance, naive-
type.logisticcharacter-Newton, modified.Newton-
type.measurecharacterdeviancedeviance, class, auc, mse, mae-
type.multinomialcharacter-ungrouped, grouped-
upper.limitsuntyped--

Internal Encoding

Starting with mlr3 v0.5.0, the order of class labels is reversed prior to model fitting to comply to the stats::glm() convention that the negative class is provided as the first factor level.

References

Friedman J, Hastie T, Tibshirani R (2010). “Regularization Paths for Generalized Linear Models via Coordinate Descent.” Journal of Statistical Software, 33(1), 1--22. doi:10.18637/jss.v033.i01 .

See also

Other Learner: mlr_learners_classif.glmnet, mlr_learners_classif.kknn, mlr_learners_classif.lda, mlr_learners_classif.log_reg, mlr_learners_classif.multinom, mlr_learners_classif.naive_bayes, mlr_learners_classif.nnet, mlr_learners_classif.qda, mlr_learners_classif.ranger, mlr_learners_classif.svm, mlr_learners_classif.xgboost, mlr_learners_regr.cv_glmnet, mlr_learners_regr.glmnet, mlr_learners_regr.kknn, mlr_learners_regr.km, mlr_learners_regr.lm, mlr_learners_regr.nnet, mlr_learners_regr.ranger, mlr_learners_regr.svm, mlr_learners_regr.xgboost

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifCVGlmnet

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.


Method selected_features()

Returns the set of selected features as reported by glmnet::predict.glmnet() with type set to "nonzero".

Usage

LearnerClassifCVGlmnet$selected_features(lambda = NULL)

Arguments

lambda

(numeric(1))
Custom lambda, defaults to the active lambda depending on parameter set.

Returns

(character()) of feature names.


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifCVGlmnet$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (requireNamespace("glmnet", quietly = TRUE)) {
  learner = mlr3::lrn("classif.cv_glmnet")
  print(learner)

  # available parameters:
learner$param_set$ids()
}
#> <LearnerClassifCVGlmnet:classif.cv_glmnet>: GLM with Elastic Net Regularization
#> * Model: -
#> * Parameters: list()
#> * Packages: mlr3, mlr3learners, glmnet
#> * Predict Types:  [response], prob
#> * Feature Types: logical, integer, numeric
#> * Properties: multiclass, selected_features, twoclass, weights
#>  [1] "alignment"            "alpha"                "big"                 
#>  [4] "devmax"               "dfmax"                "epsnr"               
#>  [7] "eps"                  "exclude"              "exmx"                
#> [10] "fdev"                 "foldid"               "gamma"               
#> [13] "grouped"              "intercept"            "keep"                
#> [16] "lambda.min.ratio"     "lambda"               "lower.limits"        
#> [19] "maxit"                "mnlam"                "mxitnr"              
#> [22] "mxit"                 "nfolds"               "nlambda"             
#> [25] "offset"               "parallel"             "penalty.factor"      
#> [28] "pmax"                 "pmin"                 "prec"                
#> [31] "predict.gamma"        "relax"                "s"                   
#> [34] "standardize"          "standardize.response" "thresh"              
#> [37] "trace.it"             "type.gaussian"        "type.logistic"       
#> [40] "type.measure"         "type.multinomial"     "upper.limits"