|
11 | 11 | #' @param data A data.frame. |
12 | 12 | #' @param outcome Name of the outcome column (string). |
13 | 13 | #' @param n_models Maximum number of candidate models to build; the agent |
14 | | -#' stops earlier when the stopping rules trigger (see `patience` and |
15 | | -#' `min_improve`). |
16 | | -#' @param patience Stopping rule: give up on an iteration (adding candidate |
| 14 | +#' stops earlier when the stopping rules trigger (see `stopping_rounds` and |
| 15 | +#' `stopping_tolerance`). |
| 16 | +#' @param stopping_rounds Stopping rule: give up on an iteration (adding candidate |
17 | 17 | #' models, or a refinement loop like "keep improving the features") after |
18 | 18 | #' this many consecutive attempts without improvement. |
19 | | -#' @param min_improve Stopping rule: an attempt only counts as an improvement |
| 19 | +#' @param stopping_tolerance Stopping rule: an attempt only counts as an improvement |
20 | 20 | #' if it beats the best validation metric so far by at least this relative |
21 | 21 | #' fraction, between 0 and 1 — e.g. `0.05` for 5%. |
22 | 22 | #' @param exclude Columns the models must not use — because they won't be |
|
38 | 38 | #' @param refine After the winning algorithm is found (and constraints pass), |
39 | 39 | #' keep iterating on its feature selection and engineering — one change per |
40 | 40 | #' attempt, same validation scheme — until the stopping rules trigger |
41 | | -#' (`patience` consecutive attempts without a relative gain of at least |
42 | | -#' `min_improve`). The refined model lands in the results as |
| 41 | +#' (`stopping_rounds` consecutive attempts without a relative gain of at least |
| 42 | +#' `stopping_tolerance`). The refined model lands in the results as |
43 | 43 | #' `<winner>_refined`, alongside the original. |
44 | 44 | #' @param validate Produce reviewable validation output for the winning model |
45 | 45 | #' (gain, calibration, grouped residuals, one-ways, PDPs) as interactive |
|
55 | 55 | #' @param verbose Stream the agent's narration to the console. |
56 | 56 | #' @param autonomous Run with no human in the loop: the agent states its plan |
57 | 57 | #' and proceeds instead of waiting for approval, and never asks questions. |
58 | | -#' Combine with a generous `n_models`/`patience` and `test_prop` for |
| 58 | +#' Combine with a generous `n_models`/`stopping_rounds` and `test_prop` for |
59 | 59 | #' unattended experimentation runs — e.g. |
60 | | -#' `atlas(d, "y", autonomous = TRUE, n_models = 10, patience = 8, |
| 60 | +#' `atlas(d, "y", autonomous = TRUE, n_models = 10, stopping_rounds = 8, |
61 | 61 | #' test_prop = 0.2)` — where the agent iterates keep/discard experiments |
62 | 62 | #' and the survivors are judged on the held-out test set at the end. |
63 | 63 | #' @param test_prop Proportion of rows (0 to <1) to hold out as a final test |
|
73 | 73 | #' Keeps long runs inside the context window and stops them paying to |
74 | 74 | #' re-read their own history. `Inf` disables. The total cost of a session |
75 | 75 | #' is reported as `cost` in the results and by `print()`. |
| 76 | +#' @param max_steps,max_runtime Hard budgets, mechanically enforced (unlike |
| 77 | +#' the stopping rules, which the agent applies itself): the maximum number |
| 78 | +#' of code executions and wall-clock seconds for the session. The agent is |
| 79 | +#' warned in tool results as a budget nears exhaustion; past the limit, |
| 80 | +#' code execution is refused and it must finalise from what it has. `Inf` |
| 81 | +#' (default) disables. Recommended for `autonomous` runs. |
76 | 82 | #' @return An object of class `atlas`: list with `models` (named list of |
77 | 83 | #' fitted models), `leaderboard` (data.frame of validation metrics), |
78 | 84 | #' `test_leaderboard` (held-out test metrics, when `test_prop > 0`), |
|
98 | 104 | atlas <- function(data, outcome, n_models = 3, goal = NULL, |
99 | 105 | constraints = NULL, chat = NULL, dir = NULL, |
100 | 106 | verbose = TRUE, max_fix_rounds = 2, |
101 | | - patience = 3, min_improve = 0.05, refine = TRUE, |
| 107 | + stopping_rounds = 3, stopping_tolerance = 0.05, refine = TRUE, |
102 | 108 | validate = TRUE, exclude = NULL, |
103 | | - autonomous = FALSE, test_prop = 0, compact_at = 1e5) { |
| 109 | + autonomous = FALSE, test_prop = 0, compact_at = 1e5, |
| 110 | + max_steps = Inf, max_runtime = Inf) { |
104 | 111 | session <- AtlasSession$new(data, outcome, n_models = n_models, goal = goal, |
105 | 112 | constraints = constraints, chat = chat, dir = dir, |
106 | | - patience = patience, min_improve = min_improve, |
| 113 | + stopping_rounds = stopping_rounds, stopping_tolerance = stopping_tolerance, |
107 | 114 | exclude = exclude, autonomous = autonomous, |
108 | | - test_prop = test_prop, compact_at = compact_at) |
| 115 | + test_prop = test_prop, compact_at = compact_at, |
| 116 | + max_steps = max_steps, max_runtime = max_runtime) |
109 | 117 | session$build(verbose = verbose, max_fix_rounds = max_fix_rounds, |
110 | 118 | refine = refine, validate = validate) |
111 | 119 | session$results() |
|
0 commit comments