Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

GLM with Elastic Net Regularization Regression Learner

Source:R/LearnerRegrCVGlmnet.R
mlr_learners_regr.cv_glmnet.Rd

Generalized linear models with elastic net regularization.Callsglmnet::cv.glmnet() from packageglmnet.

The default for hyperparameterfamily is set to"gaussian".

Dictionary

Thismlr3::Learner can be instantiated via thedictionarymlr3::mlr_learners or with the associated sugar functionmlr3::lrn():

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

Meta Information

  • Task type: “regr”

  • Predict Types: “response”

  • 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)\)
epsnumeric1e-06\([0, 1]\)
epsnrnumeric1e-08\([0, 1]\)
excludeinteger-\([1, \infty)\)
exmxnumeric250\((-\infty, \infty)\)
familycharactergaussiangaussian, poisson-
fdevnumeric1e-05\([0, 1]\)
foldiduntypedNULL-
gammauntyped--
groupedlogicalTRUETRUE, FALSE-
interceptlogicalTRUETRUE, FALSE-
keeplogicalFALSETRUE, FALSE-
lambdauntyped--
lambda.min.rationumeric-\([0, 1]\)
lower.limitsuntyped--
maxitinteger100000\([1, \infty)\)
mnlaminteger5\([1, \infty)\)
mxitinteger100\([1, \infty)\)
mxitnrinteger25\([1, \infty)\)
nfoldsinteger10\([3, \infty)\)
nlambdainteger100\([1, \infty)\)
use_pred_offsetlogicalTRUETRUE, FALSE-
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--

Offset

If aTask contains a column with theoffset role, it is automatically incorporated during training via theoffset argument inglmnet::glmnet().During prediction, the offset column from the test set is used only ifuse_pred_offset = TRUE (default), passed via thenewoffset argument inglmnet::predict.glmnet().Otherwise, if the user setsuse_pred_offset = FALSE, a zero offset is applied, effectively disabling the offset adjustment during prediction.

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.cv_glmnet,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.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::LearnerRegr ->LearnerRegrCVGlmnet

Methods

Public methods

Inherited methods


Methodnew()

Creates a new instance of thisR6 class.


Methodselected_features()

Returns the set of selected features as reported byglmnet::predict.glmnet()withtype set to"nonzero".

Usage

LearnerRegrCVGlmnet$selected_features(lambda=NULL)

Arguments

lambda

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

Returns

(character()) of feature names.


Methodclone()

The objects of this class are cloneable with this method.

Usage

LearnerRegrCVGlmnet$clone(deep=FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if(requireNamespace("glmnet", quietly=TRUE)){# Define the Learner and set parameter valueslearner=lrn("regr.cv_glmnet")print(learner)# Define a Tasktask=tsk("mtcars")# Create train and test setids=partition(task)# Train the learner on the training idslearner$train(task, row_ids=ids$train)# print the modelprint(learner$model)# importance methodif("importance"%in%learner$properties)print(learner$importance)# Make predictions for the test rowspredictions=learner$predict(task, row_ids=ids$test)# Score the predictionspredictions$score()}#> <LearnerRegrCVGlmnet:regr.cv_glmnet>: GLM with Elastic Net Regularization#> * Model: -#> * Parameters: family=gaussian, use_pred_offset=TRUE#> * Packages: mlr3, mlr3learners, glmnet#> * Predict Types:  [response]#> * Feature Types: logical, integer, numeric#> * Properties: offset, selected_features, weights#>Warning:Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per fold#>#> Call:  (if (cv) glmnet::cv.glmnet else glmnet::glmnet)(x = data, y = target,      family = "gaussian")#>#> Measure: Mean-Squared Error#>#>     Lambda Index Measure    SE Nonzero#> min  0.536    24   7.725 4.015       6#> 1se  1.797    11  11.052 6.556       4#> regr.mse#> 19.12881

[8]ページ先頭

©2009-2025 Movatter.jp