Generalized additive models. Calls mgcv::gam from package mgcv.

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.

Calls mgcv::gam from package mgcv.

Dictionary

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

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

Traits

  • Packages: mgcv

  • Predict Types: response, se

  • Feature Types: logical, integer, numeric

  • Properties: weights

References

Wood, S.N. (2017) Generalized Additive Models: An Introduction with R (2nd edition). Chapman & Hall/ CRC, Boca Raton, Florida

Key Reference on GAMs generally:

Hastie (1993) in Chambers and Hastie (1993) Statistical Models in S. Chapman and Hall.

Hastie and Tibshirani (1990) Generalized Additive Models. Chapman and Hall.

See also

Author

JazzyPierrot

Super classes

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

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage

LearnerRegrGam$new()


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

# stop example failing with warning if package not installed learner = suppressWarnings(mlr3::lrn("regr.gam")) print(learner)
#> <LearnerRegrGam:regr.gam> #> * Model: - #> * Parameters: list() #> * Packages: mgcv #> * Predict Type: response #> * Feature types: logical, integer, numeric #> * Properties: weights
# available parameters: learner$param_set$ids()
#> [1] "family" "formula" "offset" #> [4] "method" "optimizer" "scale" #> [7] "select" "knots" "sp" #> [10] "min.sp" "H" "gamma" #> [13] "paraPen" "G" "in.out" #> [16] "drop.unused.levels" "drop.intercept" "nthreads" #> [19] "irls.reg" "epsilon" "maxit" #> [22] "trace" "mgcv.tol" "mgcv.half" #> [25] "rank.tol" "nlm" "optim" #> [28] "newton" "outerPIsteps" "idLinksBases" #> [31] "scalePenalty" "efs.lspmax" "efs.tol" #> [34] "scale.est" "edge.correct" "block.size" #> [37] "unconditional"
# 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