Skip to content

Commit 03c038f

Browse files
authored
Merge branch 'tidymodels:main' into variable-fold-weights
2 parents 22754b8 + 7ac2317 commit 03c038f

File tree

76 files changed

+2702
-3504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2702
-3504
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ _cache$
1818
^LICENSE\.md$
1919
^CODE_OF_CONDUCT\.md$
2020
^man-roxygen$
21+
^\.vscode$

.github/workflows/R-CMD-check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# usethis::use_github_action("check-standard") will install it.
77
on:
88
push:
9-
branches: [main, master]
9+
branches: [main, master, 'melodie-switch']
1010
pull_request:
11-
branches: [main, master]
11+
branches: [main, master, 'melodie-switch']
1212

1313
name: R-CMD-check.yaml
1414

.github/workflows/test-coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
5-
branches: [main, master]
5+
branches: [main, master, 'melodie-switch']
66
pull_request:
7-
branches: [main, master]
7+
branches: [main, master, 'melodie-switch']
88

99
name: test-coverage.yaml
1010

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"mirai"
4+
]
5+
}

DESCRIPTION

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: tune
22
Title: Tidy Tuning Tools
3-
Version: 1.3.0.9001
3+
Version: 1.3.0.9005
44
Authors@R: c(
55
person("Max", "Kuhn", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2402-136X")),
@@ -19,22 +19,19 @@ Depends:
1919
Imports:
2020
cli (>= 3.3.0),
2121
dials (>= 1.3.0.9000),
22-
doFuture (>= 1.0.0),
2322
dplyr (>= 1.1.0),
24-
foreach,
25-
future (>= 1.33.0),
26-
future.apply,
2723
generics (>= 0.1.2),
2824
ggplot2,
2925
glue (>= 1.6.2),
3026
GPfit,
3127
hardhat (>= 1.4.0.9002),
3228
lifecycle (>= 1.0.0),
29+
parallel,
3330
parsnip (>= 1.2.1.9003),
3431
purrr (>= 1.0.0),
3532
recipes (>= 1.1.0.9001),
3633
rlang (>= 1.1.4),
37-
rsample (>= 1.2.1.9000),
34+
rsample (>= 1.3.0.9003),
3835
tailor,
3936
tibble (>= 3.1.0),
4037
tidyr (>= 1.2.0),
@@ -47,10 +44,13 @@ Suggests:
4744
C50,
4845
censored (>= 0.3.0),
4946
covr,
47+
future (>= 1.33.0),
48+
future.apply,
5049
kernlab,
5150
kknn,
5251
knitr,
5352
mgcv,
53+
mirai (>= 2.4.0),
5454
modeldata,
5555
probably,
5656
scales,
@@ -61,6 +61,7 @@ Suggests:
6161
xgboost,
6262
xml2
6363
Remotes:
64+
tidymodels/rsample,
6465
tidymodels/tailor,
6566
tidymodels/workflows
6667
Config/Needs/website: pkgdown, tidymodels, kknn, doParallel, doFuture,

NAMESPACE

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ S3method(last_fit,workflow)
4949
S3method(load_pkgs,character)
5050
S3method(load_pkgs,model_spec)
5151
S3method(load_pkgs,workflow)
52-
S3method(melodie_grid,default)
53-
S3method(melodie_grid,model_spec)
54-
S3method(melodie_grid,workflow)
5552
S3method(merge,model_spec)
5653
S3method(merge,recipe)
5754
S3method(min_grid,C5_rules)
@@ -74,6 +71,7 @@ S3method(outcome_names,recipe)
7471
S3method(outcome_names,terms)
7572
S3method(outcome_names,tune_results)
7673
S3method(outcome_names,workflow)
74+
S3method(outcome_names,workflow_variables)
7775
S3method(parameters,model_spec)
7876
S3method(parameters,recipe)
7977
S3method(parameters,workflow)
@@ -139,7 +137,6 @@ S3method(vec_restore,iteration_results)
139137
S3method(vec_restore,resample_results)
140138
S3method(vec_restore,tune_results)
141139
export(.catch_and_log)
142-
export(.catch_and_log_fit)
143140
export(.config_key_from_metrics)
144141
export(.estimate_metrics)
145142
export(.filter_perf_metrics)
@@ -220,7 +217,6 @@ export(is_workflow)
220217
export(last_fit)
221218
export(load_pkgs)
222219
export(maybe_choose_eval_time)
223-
export(melodie_grid)
224220
export(message_wrap)
225221
export(metrics_info)
226222
export(min_grid)
@@ -295,10 +291,6 @@ importFrom(dplyr,slice)
295291
importFrom(dplyr,starts_with)
296292
importFrom(dplyr,ungroup)
297293
importFrom(dplyr,vars)
298-
importFrom(foreach,"%dopar%")
299-
importFrom(foreach,foreach)
300-
importFrom(foreach,getDoParName)
301-
importFrom(future.apply,future_lapply)
302294
importFrom(generics,augment)
303295
importFrom(generics,min_grid)
304296
importFrom(generics,required_pkgs)

NEWS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
# tune (development version)
22

3+
## Changes to `tune_grid()`.
4+
5+
* A major rewrite and refactor of the underlying code that runs `tune_grid()` was made.
6+
7+
* The pattern of `.config` values has changed from `Preprocessor{num}_Model{num}` to `pre{num}_mod{num}_post{num}`.
8+
39
* The package will now log a backtrace for errors and warnings that occur during tuning. When a tuning process encounters issues, see the new `trace` column in the `collect_notes(.Last.tune.result)` output to find precisely where the error occurred (#873).
410

511
* Post-processing: new `schedule_grid()` for scheduling a grid including post-processing (#988).
612

13+
## Other Changes
14+
15+
* Introduced support for parallel processing with mirai in addition to the currently supported framework future. See `?parallelism` to learn more (#1028).
16+
17+
* Sequential and parallel processing all use the same L'Ecuyer-CMRG seeds (conditional on `parallel_over`) (#1033).
18+
19+
* `int_pctl()` now includes an option (`keep_replicates`) to retain the individual bootstrap estimates. It also processes the resamples more efficiently (#1000).
20+
21+
## Breaking Changes
22+
23+
* The `foreach` package is no longer supported. Instead, use the future or mirai packages.
24+
* The parallel backend(s) and the methods of constructing seeds for workers have changed. There will be a lack of reproducibility between objects created in this version of tune and previous versions.
25+
726
# tune 1.3.0
827

928
* The package will now warn when parallel processing has been enabled with foreach but not with future. See [`?parallelism`](https://tune.tidymodels.org/dev/reference/parallelism.html) to learn more about transitioning your code to future (#878, #866). The next version of tune will move to a pure future implementation.

R/0_imports.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
#' @importFrom cli cli_alert_danger cli_alert_info cli_alert_warning
2121
#' @importFrom cli cli_alert_success cli_alert
2222
#' @importFrom cli cli_inform cli_warn cli_abort qty
23-
#' @importFrom foreach foreach getDoParName %dopar%
2423
#' @importFrom tibble obj_sum size_sum
2524
#' @import rlang
26-
#' @importFrom future.apply future_lapply
2725

2826
# ------------------------------------------------------------------------------
2927
# Only a small number of functions in workflows.

R/case_weights.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,19 @@ extract_case_weights <- function(data, workflow) {
6161
}
6262

6363
loc <- eval_select_case_weights(col, data)
64+
if (length(loc) != 1) {
65+
# Can't happen now, make sure it doesn't happen in the future
66+
cli::cli_abort("Only a single case weight column is allowed. {length(loc)}
67+
were found: {.val {names(loc)}}.")
68+
}
6469

65-
case_weights <- data[[loc]]
70+
if (!tibble::is_tibble(data)) {
71+
data <- tibble::as_tibble(data)
72+
}
73+
case_weights <- data[, loc]
74+
case_weights <- stats::setNames(case_weights, case_weights_column_name())
6675

67-
if (!hardhat::is_case_weights(case_weights)) {
76+
if (!hardhat::is_case_weights(data[[names(loc)]])) {
6877
cli::cli_abort(
6978
"Case weights must be a supported case weights type, as determined by
7079
{.fn hardhat::is_case_weights}."

R/checks.R

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ check_parameters <- function(wflow, pset = NULL, data, grid_names = character(0)
190190
cli::format_inline(
191191
"Creating pre-processing data to finalize {num_unk} unknown parameter{?s}: {.val {unk_names}}")
192192

193-
tune_log(list(verbose = TRUE), split_labels = NULL, msg, type = "info")
193+
tune_log(list(verbose = TRUE), split_labels = NULL, task = msg, type = "info")
194194

195195
x <- workflows::.fit_pre(wflow, data)$pre$mold$predictors
196196
pset$object <- purrr::map(pset$object, dials::finalize, x = x)
@@ -436,7 +436,7 @@ check_initial <- function(x,
436436
if (ctrl$verbose) {
437437
message()
438438
msg <- cli::format_inline(" Generating a set of {nrow(x)} initial parameter results")
439-
tune_log(ctrl, split_labels = NULL, msg, type = "go")
439+
tune_log(ctrl, split_labels = NULL, task = msg, type = "go")
440440
}
441441

442442
grid_ctrl <- ctrl
@@ -452,7 +452,7 @@ check_initial <- function(x,
452452
)
453453

454454
if (ctrl$verbose) {
455-
tune_log(ctrl, split_labels = NULL, "Initialization complete", type = "success")
455+
tune_log(ctrl, split_labels = NULL, task = "Initialization complete", type = "success")
456456
message()
457457
}
458458
} else {
@@ -497,16 +497,6 @@ check_initial <- function(x,
497497
x
498498
}
499499

500-
get_objective_name <- function(x, metrics) {
501-
if (is.null(x)) {
502-
metric_data <- metrics_info(metrics)
503-
x <- metric_data$.metric[1]
504-
} else {
505-
# check for a name or acquisition function
506-
}
507-
x
508-
}
509-
510500
# ------------------------------------------------------------------------------
511501

512502
check_class_or_null <- function(x, cls = "numeric") {

0 commit comments

Comments
 (0)