TidyModels Resampling Output

I have a resampling output formatted below (res) and I would like to expand the entire tibble as a dataframe so I can see all folds, metrics AND individual data predictions. All of the data I require is in this tibble but I cannot find a function to view or return all data.

My res output is based on:
res <- wf %>% tune_grid(resamples = cv, grid = grid, metrics = metrics, control = ctr)
where wf <- workflow() %>% add_model(update_spec) %>% add_recipe(rec)

The collect_metrics function simply summarizes the tibble and does not return the data buried in the splits:
collect_metrics(res, summarize = F)
collect_metrics(res, summarize = F)
this is not what I require

The augment function simply returns exactly what I want but only for one selected best fit:
augment(m, new_data = d) %>% cbind(b)
where m is the fitted model workflow, d the predictor data and b the best fit parameters
Ideally I'd like not just the best fit parameters but each parameter set across all folds and repeats

The format of my output looks like this (res) and I'd like a function to expand out all lists into one large data frame. If I simply use unnest and specify the columns I get an error.

unnest(res, cols = c(splits, .metrics, .notes, .predictions))

Error in `list_sizes()`:
! `x[[1]]` must be a vector, not a <vfold_split/rsplit> object.
Backtrace:
 1. tidyr::unnest(res, cols = c(splits, .metrics, .notes, .predictions))
 2. tidyr:::unnest.data.frame(...)
 3. tidyr::unchop(...)
 4. tidyr:::df_unchop(...)
 5. vctrs::list_sizes(col)
splits
<list>
id
<chr>
id2
<chr>
.metrics
<list>
.notes
<list>
.predictions
<list>
<S3: vfold_split>	Repeat1	Fold01	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold02	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold03	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold04	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold05	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold06	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold07	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold08	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold09	<tibble>	<tibble>	<tibble>
<S3: vfold_split>	Repeat1	Fold10	<tibble>	<tibble>	<tibble>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.