dot-model_param_name_key: Translate names of model tuning parameters

.model_param_name_keyR Documentation

Translate names of model tuning parameters

Description

This function creates a key that connects the identifiers users make for tuning parameter names, the standardized parsnip parameter names, and the argument names to the underlying fit function for the engine.

Usage

.model_param_name_key(object, as_tibble = TRUE)

Arguments

object

A workflow or parsnip model specification.

as_tibble

A logical. Should the results be in a tibble (the default) or in a list that can facilitate renaming grid objects?

Value

A tibble with columns user, parsnip, and engine, or a list with named character vectors user_to_parsnip and parsnip_to_engine.

Examples


mod <-
 linear_reg(penalty = tune("regularization"), mixture = tune()) %>%
 set_engine("glmnet")

mod %>% .model_param_name_key()

rn <- mod %>% .model_param_name_key(as_tibble = FALSE)
rn

grid <- tidyr::crossing(regularization = c(0, 1), mixture = (0:3) / 3)

grid %>%
  dplyr::rename(!!!rn$user_to_parsnip)

grid %>%
  dplyr::rename(!!!rn$user_to_parsnip) %>%
  dplyr::rename(!!!rn$parsnip_to_engine)


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