Regression L1 and L2 Penalized Learner
Source:R/learner_penalized_regr_penalized.R
mlr_learners_regr.penalized.RdPenalized (L1 and L2) Logistic Regression.
Calls penalized::penalized() from: penalized.
Details
The penalized and unpenalized arguments in the learner are implemented slightly
differently than in penalized::penalized(). Here, there is no parameter for penalized but
instead it is assumed that every variable is penalized unless stated in the unpenalized
parameter.
Parameters
| Id | Type | Default | Levels | Range |
| epsilon | numeric | 1e-10 | \([0, \infty)\) | |
| fusedl | logical | FALSE | TRUE, FALSE | - |
| lambda1 | numeric | 0 | \([0, \infty)\) | |
| lambda2 | numeric | 0 | \([0, \infty)\) | |
| maxiter | integer | - | \([1, \infty)\) | |
| model | character | linear | linear, poisson | - |
| positive | untyped | FALSE | - | |
| standardize | logical | FALSE | TRUE, FALSE | - |
| startbeta | untyped | - | - | |
| startgamma | untyped | - | - | |
| steps | untyped | 1L | - | |
| trace | logical | TRUE | TRUE, FALSE | - |
| unpenalized | untyped | - | - |
References
Goeman, J J (2010). “L1 penalized estimation in the Cox proportional hazards model.” Biometrical journal, 52(1), 70–84.
See also
as.data.table(mlr_learners)for a table of available Learners in the running session (depending on the loaded packages).Chapter in the mlr3book: https://mlr3book.mlr-org.com/basics.html#learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Super classes
mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrPenalized
Methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$format()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$print()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3::LearnerRegr$predict_newdata_fast()
Examples
# Define the Learner
learner = lrn("regr.penalized")
print(learner)
#>
#> ── <LearnerRegrPenalized> (regr.penalized): Penalized Regression ──────────────
#> • Model: -
#> • Parameters: trace=FALSE
#> • Packages: mlr3 and penalized
#> • Predict Types: [response]
#> • Feature Types: logical, integer, numeric, factor, and ordered
#> • Encapsulation: none (fallback: -)
#> • Properties:
#> • Other settings: use_weights = 'error'
# Define a Task
task = tsk("mtcars")
# Create train and test set
ids = partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
print(learner$model)
#> Penalized linear regression object
#> 11 regression coefficients
#>
#> Loglikelihood = -40.40071
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> regr.mse
#> 25.66716