tune (version 0.0.1)

collect_predictions: Obtain and format results produced by tuning functions

Description

Obtain and format results produced by tuning functions

Usage

collect_predictions(x)

collect_metrics(x, summarize = TRUE)

Arguments

x

The results of tune_grid(), tune_bayes(), fit_resamples(), or last_fit(). For collect_predictions(), the control option save_pred = TRUE should have been used.

summarize

A logical; should metrics be summarized over resamples (TRUE) or return the values for each individual resample. Note that, if x is created by last_fit(), summarize has not effect.

Value

A tibble. The column names depend on the results and the mode of the model.

For collect_metrics() and collect_predictions(), there are columns for each tuning parameter (using the id from tune(), if any).

For collect_predictions(), there are additional columns for the resampling identifier(s), columns for the predicted values (e.g., .pred, .pred_class, etc.), and a column for the outcome(s) using the original column name(s) in the data.

collect_metrics() also has columns .metric, and .estimator. When the results are summarized, there are columns for mean, n, and std_err. When not summarized, the additional columns for the resampling identifier(s) and .estimate.

Examples

Run this code
# NOT RUN {
data("example_ames_knn")

# Summarized over resamples
collect_metrics(ames_grid_search)

# Per-resample values
collect_metrics(ames_grid_search, summarize = FALSE)

# ---------------------------------------------------------------------------

library(parsnip)
library(rsample)

lm_mod <-linear_reg() %>% set_engine("lm")
set.seed(93599150)
car_folds <- vfold_cv(mtcars)
ctrl <- control_resamples(save_pred = TRUE)

resampled <- fit_resamples(mpg ~ ., lm_mod, resamples = car_folds, control = ctrl)
collect_predictions(resampled)
# }

Run the code above in your browser using DataLab