Classification Fast Generalized Additive Model Learner
Source:R/learner_mgcv_classif_bam.R
mlr_learners_classif.bam.RdFast 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
familyis alwaysbinomial, so it is not exposed as a hyperparameter.controlis passed tomgcv::gam.control()as a list. Unlikeclassif.gam, the individual control options are not exposed as hyperparameters, becausenthreadsis both a control option and an argument ofmgcv::bam().discreteis a parameter of bothmgcv::bam()andmgcv::predict.bam(), with different defaults. Only the training parameter is exposed, and prediction uses the default ofmgcv::predict.bam().Only the training parameter
nthreadsis tagged with"threads", somlr3::set_threads()does not change the prediction parametern.threads.
Meta Information
Task type: “classif”
Predict Types: “response”, “prob”
Feature Types: “logical”, “integer”, “numeric”, “factor”
Required Packages: mlr3, mlr3extralearners, mgcv
Parameters
| Id | Type | Default | Levels | Range |
| formula | untyped | - | - | |
| method | character | fREML | fREML, GCV.Cp, GACV.Cp, REML, P-REML, ML, P-ML | - |
| control | untyped | list() | - | |
| select | logical | FALSE | TRUE, FALSE | - |
| scale | numeric | 0 | \((-\infty, \infty)\) | |
| gamma | numeric | 1 | \([1, \infty)\) | |
| knots | untyped | NULL | - | |
| sp | untyped | NULL | - | |
| min.sp | untyped | NULL | - | |
| paraPen | untyped | NULL | - | |
| chunk.size | integer | 10000 | \([1, \infty)\) | |
| rho | numeric | 0 | \((-\infty, \infty)\) | |
| AR.start | untyped | NULL | - | |
| discrete | logical | FALSE | TRUE, FALSE | - |
| nthreads | integer | 1 | \([1, \infty)\) | |
| use.chol | logical | FALSE | TRUE, FALSE | - |
| samfrac | numeric | 1 | \([0, 1]\) | |
| coef | untyped | NULL | - | |
| drop.unused.levels | logical | TRUE | TRUE, FALSE | - |
| G | untyped | NULL | - | |
| drop.intercept | logical | NULL | TRUE, FALSE | - |
| in.out | untyped | NULL | - | |
| nei | untyped | NULL | - | |
| cluster | untyped | NULL | - | |
| gc.level | integer | 0 | \([0, \infty)\) | |
| terms | untyped | NULL | - | |
| exclude | untyped | NULL | - | |
| block.size | integer | 50000 | \((-\infty, \infty)\) | |
| n.threads | integer | 1 | \([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
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/chapters/chapter2/data_and_basic_modeling.html#sec-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::LearnerClassif -> LearnerClassifBam
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::LearnerClassif$predict_newdata_fast()
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