Skip to content

Replacing the magrittr pipe #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ License: MIT + file LICENSE
URL: https://tune.tidymodels.org/, https://github.com/tidymodels/tune
BugReports: https://github.com/tidymodels/tune/issues
Depends:
R (>= 4.0)
R (>= 4.1)
Imports:
cli (>= 3.3.0),
dials (>= 1.3.0.9000),
Expand Down Expand Up @@ -50,22 +50,22 @@ Suggests:
kknn,
knitr,
modeldata,
probably,
probably (>= 1.0.3.9001),
scales,
spelling,
splines2,
testthat (>= 3.0.0),
xgboost,
xml2
Remotes:
tidymodels/dials,
tidymodels/hardhat,
tidymodels/parsnip,
tidymodels/probably,
tidymodels/recipes,
tidymodels/rsample,
tidymodels/tailor,
tidymodels/workflows,
tidymodels/dials,
tidymodels/probably
tidymodels/workflows
Config/Needs/website: pkgdown, tidymodels, kknn, doParallel, doFuture,
tidyverse/tidytemplate
Config/testthat/edition: 3
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ importFrom(cli,qty)
importFrom(dials,encode_unit)
importFrom(dials,is_unknown)
importFrom(dials,parameters)
importFrom(dplyr,"%>%")
importFrom(dplyr,all_of)
importFrom(dplyr,anti_join)
importFrom(dplyr,arrange)
Expand Down
2 changes: 1 addition & 1 deletion R/0_imports.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' @importFrom dplyr filter select %>% full_join mutate bind_rows case_when vars
#' @importFrom dplyr filter select full_join mutate bind_rows case_when vars
#' @importFrom dplyr all_of ungroup slice bind_cols pull sample_n desc anti_join
#' @importFrom dplyr distinct arrange rename mutate_if starts_with inner_join
#' @importFrom dplyr last
Expand Down
26 changes: 13 additions & 13 deletions R/acquisition.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ predict.prob_improve <-
}

new_data <-
new_data %>%
new_data |>
mutate(.sd = ifelse(.sd <= object$eps, object$eps, .sd))

if (maximize) {
new_data <-
new_data %>%
new_data |>
mutate(delta = ((.mean - best - trade_off) / .sd))
} else {
new_data <-
new_data %>%
new_data |>
mutate(delta = ((trade_off + best - .mean) / .sd))
}
new_data %>%
dplyr::mutate(objective = pnorm(delta)) %>%
new_data |>
dplyr::mutate(objective = pnorm(delta)) |>
dplyr::select(objective)
}

Expand Down Expand Up @@ -137,23 +137,23 @@ predict.exp_improve <- function(object, new_data, maximize, iter, best, ...) {
}

new_data <-
new_data %>%
new_data |>
mutate(sd_trunc = ifelse(.sd <= object$eps, object$eps, .sd))

if (maximize) {
new_data <- new_data %>% mutate(delta = .mean - best - trade_off)
new_data <- new_data |> mutate(delta = .mean - best - trade_off)
} else {
new_data <- new_data %>% mutate(delta = trade_off + best - .mean)
new_data <- new_data |> mutate(delta = trade_off + best - .mean)
}
new_data <-
new_data %>%
new_data |>
mutate(
snr = delta / sd_trunc,
z = ifelse(.sd <= object$eps, 0, snr),
objective = (delta * pnorm(z)) + (sd_trunc * dnorm(z))
)

new_data %>% dplyr::select(objective)
new_data |> dplyr::select(objective)
}


Expand Down Expand Up @@ -188,9 +188,9 @@ predict.conf_bound <- function(object, new_data, maximize, iter, ...) {

# `tune` is setup to always maximize the objective function
if (maximize) {
new_data <- new_data %>% mutate(objective = .mean + kappa * .sd)
new_data <- new_data |> mutate(objective = .mean + kappa * .sd)
} else {
new_data <- new_data %>% mutate(objective = -(.mean + kappa * .sd))
new_data <- new_data |> mutate(objective = -(.mean + kappa * .sd))
}
new_data %>% dplyr::select(objective)
new_data |> dplyr::select(objective)
}
4 changes: 2 additions & 2 deletions R/case_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#' library(parsnip)
#' library(dplyr)
#'
#' frequency_weights(1:10) %>%
#' frequency_weights(1:10) |>
#' .use_case_weights_with_yardstick()
#'
#' importance_weights(seq(1, 10, by = .1))%>%
#' importance_weights(seq(1, 10, by = .1))|>
#' .use_case_weights_with_yardstick()
.use_case_weights_with_yardstick <- function(x) {
UseMethod(".use_case_weights_with_yardstick")
Expand Down
10 changes: 5 additions & 5 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ check_initial <- function(x,
param_nms <- .get_tune_parameter_names(x)
if (inherits(x, "tune_race")) {
num_resamples <-
x %>%
collect_metrics(summarize = FALSE) %>%
x |>
collect_metrics(summarize = FALSE) |>
dplyr::count(.config)
max_resamples <- max(num_resamples$n)
configs <- num_resamples$.config[num_resamples$n == max_resamples]
Expand All @@ -461,8 +461,8 @@ check_initial <- function(x,
x$.order <- NULL
} else {
num_grid <-
collect_metrics(x) %>%
dplyr::distinct(!!!rlang::syms(param_nms)) %>%
collect_metrics(x) |>
dplyr::distinct(!!!rlang::syms(param_nms)) |>
nrow()
}
if (any(checks == "bayes")) {
Expand All @@ -472,7 +472,7 @@ check_initial <- function(x,
}
}
if (!any(names(x) == ".iter")) {
x <- x %>% dplyr::mutate(.iter = 0L)
x <- x |> dplyr::mutate(.iter = 0L)
}
x
}
Expand Down
Loading
Loading