Learn R Programming

tidysynthesis (version 0.1.2)

synth_spec_model_api: Add, update, or remove custom models from a synth_spec object

Description

Add, update, or remove custom models from a synth_spec object

Usage

add_custom_models(synth_spec, ...)

update_custom_models(synth_spec, ...)

remove_custom_models(synth_spec)

Value

A new synth_spec object.

A new synth_spec object with added custom models.

A new synth_spec object with updated custom models.

A new synth_spec object with removed custom models.

Arguments

synth_spec

A synth_spec object

...

Optional named lists with two elements, vars and model, mapping variable names to model_spec objects from library(parsnip).

Examples

Run this code

synth_spec <- synth_spec()

dt_reg_mod <- parsnip::decision_tree() |>
  parsnip::set_engine("rpart") |>
  parsnip::set_mode("regression")

add_custom_models(
  synth_spec = synth_spec, 
  list("vars" = c("a", "b", "c"), "model" = dt_reg_mod)
)


synth_spec <- synth_spec()

dt_reg_mod <- parsnip::decision_tree() |>
  parsnip::set_engine("rpart") |>
  parsnip::set_mode("regression")

update_custom_models(
  synth_spec = synth_spec, 
  list("vars" = c("a", "b", "c"), "model" = dt_reg_mod)
)


synth_spec <- synth_spec()

dt_reg_mod <- parsnip::decision_tree() |>
  parsnip::set_engine("rpart") |>
  parsnip::set_mode("regression")

synth_spec <- update_custom_models(
  synth_spec = synth_spec, 
  list("vars" = c("a", "b", "c"), "model" = dt_reg_mod)
)

remove_custom_models(synth_spec = synth_spec)

Run the code above in your browser using DataLab