Skip to contents

Fast generalized additive models for large datasets. Calls mgcv::bam() from package mgcv with a binomial family. For smaller datasets, use classif.gam instead.

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 model 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::bam(). No offset is applied during prediction for this learner.

Custom mlr3 parameters

  • family is always binomial, so it is not exposed as a hyperparameter.

  • control is passed to mgcv::gam.control() as a list. Unlike classif.gam, the individual control options are not exposed as hyperparameters, because nthreads is both a control option and an argument of mgcv::bam().

  • discrete is a parameter of both mgcv::bam() and mgcv::predict.bam(), with different defaults. Only the training parameter is exposed, and prediction uses the default of mgcv::predict.bam().

  • Only the training parameter nthreads is tagged with "threads", so mlr3::set_threads() does not change the prediction parameter n.threads.

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.bam")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

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

  • Required Packages: mlr3, mlr3extralearners, mgcv

Parameters

IdTypeDefaultLevelsRange
formulauntyped--
methodcharacterfREMLfREML, GCV.Cp, GACV.Cp, REML, P-REML, ML, P-ML-
controluntypedlist()-
selectlogicalFALSETRUE, FALSE-
scalenumeric0\((-\infty, \infty)\)
gammanumeric1\([1, \infty)\)
knotsuntypedNULL-
spuntypedNULL-
min.spuntypedNULL-
paraPenuntypedNULL-
chunk.sizeinteger10000\([1, \infty)\)
rhonumeric0\((-\infty, \infty)\)
AR.startuntypedNULL-
discretelogicalFALSETRUE, FALSE-
nthreadsinteger1\([1, \infty)\)
use.chollogicalFALSETRUE, FALSE-
samfracnumeric1\([0, 1]\)
coefuntypedNULL-
drop.unused.levelslogicalTRUETRUE, FALSE-
GuntypedNULL-
drop.interceptlogicalNULLTRUE, FALSE-
in.outuntypedNULL-
neiuntypedNULL-
clusteruntypedNULL-
gc.levelinteger0\([0, \infty)\)
termsuntypedNULL-
excludeuntypedNULL-
block.sizeinteger50000\((-\infty, \infty)\)
n.threadsinteger1\([1, \infty)\)

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

See also

Author

Tino-Rg

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifBam

Methods

Inherited methods


LearnerClassifBam$new()

Creates a new instance of this R6 class.

Usage


LearnerClassifBam$clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifBam$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# simple example
t = tsk("spam")$filter(1:1000)
l = lrn("classif.bam")
l$param_set$set_values(
  formula = type ~ s(george, k = 3) + s(charDollar, k = 3) + s(edu)
)
l$train(t)
l$model
#> 
#> Family: binomial 
#> Link function: logit 
#> 
#> Formula:
#> type ~ s(george, k = 3) + s(charDollar, k = 3) + s(edu)
#> 
#> Estimated degrees of freedom:
#> 0.368 0.368 0.368  total = 1.47 
#> 
#> fREML score: -40.99272