summary() returns the facts of a final fit as values: the tuning run on
all the data, the tuner and its counts, how many candidates it scored,
and the selected values.
Arguments
- object
A
nested_final_fitfromnested_final_fit().- ...
Not used, and must be empty.
- x
A
summary.nested_final_fitobject fromsummary.nested_final_fit().
Value
summary() returns a summary.nested_final_fit, a list with these
components:
tuning_label, the tuning run's resampling labeltuner, the tune or finetune function that rancandidates, the number of candidates the run scoredinitial,initial_requested,iterations_completedanditerations_requested, the counts of an iterating searchselection, the selected parameter valuesselectandfirst_metric, asextract_procedure()records themestimate, alwaysNULL
print() returns x, invisibly.
Details
The estimate component is always NULL, because the number to report
is not stored on the fit. It is the nested estimate from
collect_metrics() on the nested run the fit was built from. The nested
estimate describes the procedure that produced this model, not the fitted
model itself.
The four iteration counts are NULL for a grid search or a race. On a fit
with nothing to tune, candidates is 0, selection is empty, and the
other components but tuner are NULL.
Examples
data(mtcars)
rec <- recipes::recipe(mpg ~ ., data = mtcars) |>
recipes::step_pca(recipes::all_predictors(), num_comp = tune::tune())
wf <- workflows::workflow(rec, parsnip::linear_reg())
set.seed(1)
folds <- nested_resamples(
mtcars,
outside = rsample::vfold_cv(v = 2),
inside = rsample::vfold_cv(v = 2)
)
set.seed(2)
res <- nested_tune_grid(wf, folds, grid = data.frame(num_comp = 1:2))
set.seed(3)
final <- nested_final_fit(wf, res)
summary(final)
#>
#> ── Nested cross-validation final fit ──────────────────────────────────
#> Full-data tuning: 2-fold cross-validation
#> Procedure: grid search, 2 candidates scored
#> Candidates scored: 2
#>
#> ── Selected parameters ──
#>
#> Selecting metric: rmse
#> num_comp: 1
#>
#> ── Estimate ──
#>
#> ℹ Report the nested estimate from `collect_metrics()` on the results
#> object this fit was built from. For a fit built from a workflow set,
#> that is this workflow's rows of `collect_metrics()` on the set. That
#> holds for a workflow chosen before seeing the set's estimates. It
#> describes the procedure that produced this model, and it is the
#> number to report for this model.
#> ℹ The tuning run above has metrics, but selection consumed them.
#> `extract_tune_results()` reaches them, and every one is a
#> selection-time quantity, optimistically biased as a claim about this
#> model.
