-
Notifications
You must be signed in to change notification settings - Fork 15
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
Standardize group arguments in functions #105
Conversation
R/cal-estimate-beta.R
Outdated
..., | ||
group = NULL) { | ||
stop_null_parameters(parameters) | ||
|
||
check_group_argument({{ group }}, .data) | ||
.data <- dplyr::group_by(.data, dplyr::across({{ group }})) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All *.data.frame()
functions calls check_group_argument()
and applies dplyr::group_by()
with the group. This does nothing if group = NULL
group <- expr(.config) | ||
} | ||
|
||
cal_plot_breaks_impl( | ||
tune_args <- tune_results_args( | ||
.data = .data, | ||
truth = {{ truth }}, | ||
estimate = {{ estimate }}, | ||
group = {{ group }}, | ||
event_level = event_level, | ||
... | ||
) | ||
|
||
cal_plot_breaks_impl( | ||
.data = tune_args$predictions, | ||
truth = !!tune_args$truth, | ||
estimate = !!tune_args$estimate, | ||
group = !!tune_args$group, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All *tune.results()
are changed to use tune_results_args()
.
if (quo_is_null(group)) { | ||
.data[[".config"]] <- NULL | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there isn't a group variable, e.i. .config
is constant, it is removed from the plotting data.
This makes it easier to test that faceting isn't done with constant .config
if (dplyr::n_distinct(.data[[".predictions"]][[1]][[".config"]]) > 1) { | ||
group <- quo(.config) | ||
} else { | ||
group <- quo(NULL) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the part that detects if there are more than 1 unique .config
For multinomial outcomes, much (but not all) of the infrastructure make a series of 1:all problems and applies binomial methods. While the automatic detection of hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
library(tidymodels)
library(probably)
#>
#> Attaching package: 'probably'
#> The following objects are masked from 'package:base':
#>
#> as.factor, as.ordered tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L) Created on 2023-05-10 with reprex v2.0.2 (using |
3 similar comments
For multinomial outcomes, much (but not all) of the infrastructure make a series of 1:all problems and applies binomial methods. While the automatic detection of hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
library(tidymodels)
library(probably)
#>
#> Attaching package: 'probably'
#> The following objects are masked from 'package:base':
#>
#> as.factor, as.ordered tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L) Created on 2023-05-10 with reprex v2.0.2 (using |
For multinomial outcomes, much (but not all) of the infrastructure make a series of 1:all problems and applies binomial methods. While the automatic detection of hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
library(tidymodels)
library(probably)
#>
#> Attaching package: 'probably'
#> The following objects are masked from 'package:base':
#>
#> as.factor, as.ordered tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L) Created on 2023-05-10 with reprex v2.0.2 (using |
For multinomial outcomes, much (but not all) of the infrastructure make a series of 1:all problems and applies binomial methods. While the automatic detection of hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L)
#> Error in hpc_cv %>% mutate(.config = sample(letters[1:2], nrow(hpc_cv), : could not find function "%>%"
library(tidymodels)
library(probably)
#>
#> Attaching package: 'probably'
#> The following objects are masked from 'package:base':
#>
#> as.factor, as.ordered tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L) Created on 2023-05-10 with reprex v2.0.2 (using |
if group is null and .config is present, return .config
That should be fixed now library(tidymodels)
library(probably)
#>
#> Attaching package: 'probably'
#> The following objects are masked from 'package:base':
#>
#> as.factor, as.ordered
hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_windowed(truth = obs, VF:L) hpc_cv %>%
mutate(.config = sample(letters[1:2], nrow(hpc_cv), replace = TRUE)) %>%
cal_plot_breaks(truth = obs, VF:L) Created on 2023-05-11 with reprex v2.0.2 |
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
This PR aims to tackle part of #104. Change 1 specifically.
While it might seems strange, I'm sticking with
group
over.by
, as it is consistent with the existing codebase. Once this is done, I will swap everything over to.by
as part of Change 2.group
argument tocal_estimate_*.data.frame()
functionsgroup
argument tocal_plot_.*.data.frame()
functions.config
in call_estimate_*.tune_results()` functions.config
in call_plot_*.tune_results()` functions