Regression Generalized Additive Model Learner
Source:R/learner_mgcv_regr_gam.R
mlr_learners_regr.gam.RdGeneralized additive models. Calls mgcv::gam() from package mgcv.
Formula
A gam formula specific to the task at hand is required for the formula
parameter (see example and ?mgcv::formula.gam). Beware, if no formula is provided, a fallback formula is
used that will make the gam behave like a glm (this behavior is required
for the unit tests). Only features specified in the formula will be used,
superseding columns with col_roles "feature" in the task.
Offset
If a Task contains a column with the offset role, it is automatically
incorporated during training via the offset argument in mgcv::gam().
No offset is applied during prediction for this learner.
Meta Information
Task type: “regr”
Predict Types: “response”, “se”
Feature Types: “logical”, “integer”, “numeric”, “factor”
Required Packages: mlr3, mlr3extralearners, mgcv
Parameters
| Id | Type | Default | Levels | Range |
| family | character | gaussian | gaussian, poisson | - |
| formula | untyped | - | - | |
| method | character | GCV.Cp | GCV.Cp, GACV.Cp, REML, P-REML, ML, P-ML | - |
| optimizer | untyped | c("outer", "newton") | - | |
| scale | numeric | 0 | \((-\infty, \infty)\) | |
| select | logical | FALSE | TRUE, FALSE | - |
| knots | untyped | NULL | - | |
| sp | untyped | NULL | - | |
| min.sp | untyped | NULL | - | |
| H | untyped | NULL | - | |
| gamma | numeric | 1 | \([1, \infty)\) | |
| paraPen | untyped | NULL | - | |
| G | untyped | NULL | - | |
| in.out | untyped | NULL | - | |
| drop.unused.levels | logical | TRUE | TRUE, FALSE | - |
| drop.intercept | logical | FALSE | TRUE, FALSE | - |
| nthreads | integer | 1 | \([1, \infty)\) | |
| irls.reg | numeric | 0 | \([0, \infty)\) | |
| epsilon | numeric | 1e-07 | \([0, \infty)\) | |
| maxit | integer | 200 | \((-\infty, \infty)\) | |
| trace | logical | FALSE | TRUE, FALSE | - |
| mgcv.tol | numeric | 1e-07 | \([0, \infty)\) | |
| mgcv.half | integer | 15 | \([0, \infty)\) | |
| rank.tol | numeric | 1.490116e-08 | \([0, \infty)\) | |
| nlm | untyped | list() | - | |
| optim | untyped | list() | - | |
| newton | untyped | list() | - | |
| outerPIsteps | integer | 0 | \([0, \infty)\) | |
| idLinksBases | logical | TRUE | TRUE, FALSE | - |
| scalePenalty | logical | TRUE | TRUE, FALSE | - |
| efs.lspmax | integer | 15 | \([0, \infty)\) | |
| efs.tol | numeric | 0.1 | \([0, \infty)\) | |
| scale.est | character | fletcher | fletcher, pearson, deviance | - |
| nei | untyped | - | - | |
| ncv.threads | integer | 1 | \([1, \infty)\) | |
| edge.correct | logical | FALSE | TRUE, FALSE | - |
| block.size | integer | 1000 | \((-\infty, \infty)\) | |
| unconditional | logical | FALSE | TRUE, FALSE | - |
References
Hastie, J T, Tibshirani, J R (2017). Generalized additive models. Routledge.
Wood, Simon (2012). “mgcv: Mixed GAM Computation Vehicle with GCV/AIC/REML smoothness estimation.”
Super classes
mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrGam
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
# simple example
t = tsk("mtcars")
l = lrn("regr.gam")
l$param_set$values$formula = mpg ~ cyl + am + s(disp) + s(hp)
l$train(t)
l$model
#>
#> Family: gaussian
#> Link function: identity
#>
#> Formula:
#> mpg ~ cyl + am + s(disp) + s(hp)
#>
#> Estimated degrees of freedom:
#> 6.86 1.00 total = 10.86
#>
#> GCV score: 4.851986