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
# Safely make fitted workflowinternal_make_fitted_wflw<-function(.model_tbl, .splits_obj){
# Tidyeval ----model_tbl<-.model_tblsplits_obj<-.splits_objcol_nms<- colnames(model_tbl)
# Checks ----if (!inherits(model_tbl, "tidyaml_mod_spec_tbl")){
rlang::abort(
message="'.model_tbl' must inherit a class of 'tidyaml_mod_spec_tbl",
use_cli_format=TRUE
)
}
if (!"wflw"%in%col_nms){
rlang::abort(
message="Missing the column 'wflw'",
use_cli_format=TRUE
)
}
if (!".model_id"%in%col_nms){
rlang::abort(
message="Missing the column '.model_id'",
use_cli_format=TRUE
)
}
# Manipulation# Make a group split object listmodels_list<-model_tbl %>%
dplyr::group_split(.model_id)
# Make the fitted workflow object using purrr imapfitted_wflw_list<-models_list %>%
purrr::imap(
.f=function(obj, id){
# Pull the workflow column and then pluck itwflw<-obj %>% dplyr::pull(6) %>% pluck(1)
# Create a safe parsnip::fit functionsafe_parsnip_fit<-purrr::safely(
parsnip::fit,
otherwise="Error - Could not fit the workflow.",
quiet=FALSE
)
# Return the fitted workflowret<- safe_parsnip_fit(
wflw, data=rsample::training(splits_obj$splits)
)
res<-ret %>% purrr::pluck("result")
return(res)
}
)
return(fitted_wflw_list)
}
Function:
Example:
The text was updated successfully, but these errors were encountered: