r descr_models("gen_additive_mod", "mgcv")

Tuning Parameters

defaults <- 
  tibble::tibble(parsnip = c("select_features", "adjust_deg_free"),
                 default = c("FALSE", "1.0"))

param <-
  gen_additive_mod() %>% 
  set_engine("mgcv") %>% 
  make_parameter_list(defaults)

This model has r nrow(param) tuning parameters:

param$item

Translation from parsnip to the original package (regression)

gen_additive_mod(adjust_deg_free = numeric(1), select_features = logical(1)) %>% 
  set_engine("mgcv") %>% 
  set_mode("regression") %>% 
  translate()

Translation from parsnip to the original package (classification)

gen_additive_mod(adjust_deg_free = numeric(1), select_features = logical(1)) %>% 
  set_engine("mgcv") %>% 
  set_mode("classification") %>% 
  translate()

Model fitting

This model should be used with a model formula so that smooth terms can be specified. For example:

library(mgcv)
library(mgcv)
gen_additive_mod() %>% 
  set_engine("mgcv") %>% 
  set_mode("regression") %>% 
  fit(mpg ~ wt + gear + cyl + s(disp, k = 10), data = mtcars)

The smoothness of the terms will need to be manually specified (e.g., using s(x, df = 10)) in the formula. Tuning can be accomplished using the adjust_deg_free parameter.

When using a workflow, pass the model formula to [workflows::add_model()]'s formula argument, and a simplified preprocessing formula elsewhere.

spec <- 
  gen_additive_mod() %>% 
  set_engine("mgcv") %>% 
  set_mode("regression")

workflow() %>% 
  add_model(spec, formula = mpg ~ wt + gear + cyl + s(disp, k = 10)) %>% 
  add_formula(mpg ~ wt + gear + cyl + disp) %>% 
  fit(data = mtcars) %>% 
  extract_fit_engine()

To learn more about the differences between these formulas, see [?model_formula][parsnip::model_formula].

Preprocessing requirements


Case weights


Saving fitted model objects


References



Try the parsnip package in your browser

Any scripts or data that you put into this service are public.

parsnip documentation built on June 24, 2024, 5:14 p.m.