Skip to contents

Generalized 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.

Dictionary

This Learner can be instantiated via lrn():

lrn("regr.gam")

Meta Information

  • Task type: “regr”

  • Predict Types: “response”, “se”

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

  • Required Packages: mlr3, mlr3extralearners, mgcv

Parameters

IdTypeDefaultLevelsRange
familycharactergaussiangaussian, poisson-
formulauntyped--
offsetuntypedNULL-
methodcharacterGCV.CpGCV.Cp, GACV.Cp, REML, P-REML, ML, P-ML-
optimizeruntypedc("outer", "newton")-
scalenumeric0\((-\infty, \infty)\)
selectlogicalFALSETRUE, FALSE-
knotsuntypedNULL-
spuntypedNULL-
min.spuntypedNULL-
HuntypedNULL-
gammanumeric1\([1, \infty)\)
paraPenuntypedNULL-
GuntypedNULL-
in.outuntypedNULL-
drop.unused.levelslogicalTRUETRUE, FALSE-
drop.interceptlogicalFALSETRUE, FALSE-
nthreadsinteger1\([1, \infty)\)
irls.regnumeric0\([0, \infty)\)
epsilonnumeric1e-07\([0, \infty)\)
maxitinteger200\((-\infty, \infty)\)
tracelogicalFALSETRUE, FALSE-
mgcv.tolnumeric1e-07\([0, \infty)\)
mgcv.halfinteger15\([0, \infty)\)
rank.tolnumeric1.490116e-08\([0, \infty)\)
nlmuntypedlist()-
optimuntypedlist()-
newtonuntypedlist()-
outerPIstepsinteger0\([0, \infty)\)
idLinksBaseslogicalTRUETRUE, FALSE-
scalePenaltylogicalTRUETRUE, FALSE-
efs.lspmaxinteger15\([0, \infty)\)
efs.tolnumeric0.1\([0, \infty)\)
scale.estcharacterfletcherfletcher, pearson, deviance-
neiuntyped--
ncv.threadsinteger1\([1, \infty)\)
edge.correctlogicalFALSETRUE, FALSE-
block.sizeinteger1000\((-\infty, \infty)\)
unconditionallogicalFALSETRUE, 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.”

Author

pierrecamilleri

Super classes

mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrGam

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerRegrGam$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# simple example
t = mlr3::tsk("mtcars")
l = mlr3::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