Skip to content

Add outcome_names() method for workflows using add_variables() #994

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

topepo
Copy link
Member

@topepo topepo commented Mar 20, 2025

Closes #993

@topepo topepo requested a review from hfrick April 10, 2025 20:35
Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm missing some of the context in which this is (going to be) called, so I got two questions :D


#' @export
#' @rdname outcome_names
outcome_names.tune_results <- function(x, ..., call = caller_env()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this change in function signature for tune_results objects? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome to suggest a change.

Comment on lines +64 to +69
cli::cli_abort(
"To determine the outcome names when {.fn add_variables} is used, please
pass the training set data to the {.arg data} argument.",
call = call
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an error message for the user or for us?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, digging around a bit more here and I think there is a little messaging mismatch to resolve in that error message:

Do you mean that the user of outcome_names() should use the data argument of outcome_names()? The user of outcome_names() is presumably just us since outcome_names() is labeled with @keywords internal. In that case, I wouldn't pass in the call to cli_abort() and possibly remove the reference to add_variables(). The context of how we got into this probably lives better elsewhere, likely wherever we call it from and need to add data, so in tune_grid() or int_pctl().

If you mean the general tidymodels user the current error message is probably confusing: they only call tune_grid() or int_pctl() and couldn't use that data argument to outcome_names(). tune_grid() does not have a data argument and int_pctl() has .data but that is not the same as the data for outcome_name(). (And imagining a very desperate user, looking into the mentioned add_variables() also does not reveal a data argument.)

I'm guessing path 1 is the right one here?


#' @export
#' @rdname outcome_names
outcome_names.tune_results <- function(x, ..., call = caller_env()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outcome_names.tune_results <- function(x, ..., call = caller_env()) {
outcome_names.tune_results <- function(x, ...) {

I don't think the addition is necessary (and tests pass without it) so I'd just leave things as is.

Comment on lines +64 to +69
cli::cli_abort(
"To determine the outcome names when {.fn add_variables} is used, please
pass the training set data to the {.arg data} argument.",
call = call
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, digging around a bit more here and I think there is a little messaging mismatch to resolve in that error message:

Do you mean that the user of outcome_names() should use the data argument of outcome_names()? The user of outcome_names() is presumably just us since outcome_names() is labeled with @keywords internal. In that case, I wouldn't pass in the call to cli_abort() and possibly remove the reference to add_variables(). The context of how we got into this probably lives better elsewhere, likely wherever we call it from and need to add data, so in tune_grid() or int_pctl().

If you mean the general tidymodels user the current error message is probably confusing: they only call tune_grid() or int_pctl() and couldn't use that data argument to outcome_names(). tune_grid() does not have a data argument and int_pctl() has .data but that is not the same as the data for outcome_name(). (And imagining a very desperate user, looking into the mentioned add_variables() also does not reveal a data argument.)

I'm guessing path 1 is the right one here?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot get outcome names for workflows using add_variables()
2 participants