You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update the internal_make_spec_tbl() in order to add an extra class to the parsnip model specification that is a combination of the parsnip engine and the parsnip function.
Currently the output and class output is as follows:
internal_make_spec_tbl<-function(.model_tbl){
# Tidyeval ----model_tbl<-.model_tbl# Checks ----if (!inherits(model_tbl, "tidyaml_base_tbl")){
rlang::abort(
message="The model tibble must come from the make base tbl function.",
use_cli_format=TRUE
)
}
# Manipulationmodel_factor_tbl<-model_tbl %>%
dplyr::mutate(.model_id=dplyr::row_number() |>forcats::as_factor()) |>dplyr::select(.model_id, dplyr::everything())
# Make a group split object listmodels_list<-model_factor_tbl %>%
dplyr::group_split(.model_id)
# Make the Workflow Object using purrr imapmodel_spec<-models_list %>%
purrr::imap(
.f=function(obj, id){
# Pull the model column and then pluck the modelpe<-obj|>dplyr::pull(2) |>purrr::pluck(1)
pm<-obj|>dplyr::pull(3) |>purrr::pluck(1)
pf<-obj|>dplyr::pull(4) |>purrr::pluck(1)
ret<- match.fun(pf)(mode=pm, engine=pe)
# Add parsnip engine and fns as class
class(ret) <- c(
class(ret),
paste0(base::tolower(pe), "_", base::tolower(pf))
)
# Return the resultreturn(ret)
}
)
# Return# Make sure to return as a tibblemodel_spec_ret<-model_factor_tbl|>dplyr::mutate(model_spec=model_spec) |>dplyr::mutate(.model_id= as.integer(.model_id))
return(model_spec_ret)
}
Update the
internal_make_spec_tbl()
in order to add an extra class to the parsnip model specification that is a combination of the parsnip engine and the parsnip function.Currently the output and class output is as follows:
Example:
The text was updated successfully, but these errors were encountered: