module_trials() summarizes the trials that optimize_grid() recorded on a
module: how many were run, the best trial, its score and parameters, and
the mean and standard error of all trial scores. It reads only the
grid-search trials in module$state$trials, which optimize_grid() and
GridSearchTeleprompter() write. For other optimizers, use
optimization_result() or top_trials().
Usage
module_trials(module, objective = c("maximize", "minimize"))Value
A one-row tibble with columns:
n_trials: number of trials.best_trial: identifier of the best trial.best_score: its score.mean_score,std_error: mean and standard error of the trial scores.best_params: list-column with the best trial's parameters.trials: list-column with the full trials tibble.
Without trials, n_trials is 0 and the scores are NA. When every trial
failed, a warning is raised and the scores are NA.
See also
Other grid search:
GridSearchTeleprompter(),
module_metrics(),
module_parameters(),
optimize_grid()
Examples
mod <- module(signature("text -> sentiment"))
module_trials(mod)
#> # A tibble: 1 × 7
#> n_trials best_trial best_score mean_score std_error best_params trials
#> <int> <int> <dbl> <dbl> <dbl> <list> <list>
#> 1 0 NA NA NA NA <NULL> <tibble>
if (FALSE) { # \dontrun{
optimize_grid(
mod,
data = devset,
metric = metric_exact_match(field = "sentiment"),
grid = data.frame(reasoning_effort = c("none", "low", "medium")),
.llm = ellmer::chat_openai(model = "gpt-6-luna")
)
module_trials(mod)$best_params
} # }