Skip to content
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

add collect_metrics() argument to pivot output #839

Merged
merged 3 commits into from
Feb 12, 2024
Merged

Conversation

simonpcouch
Copy link
Contributor

A follow-up on #689.

Still needs tests for survival and finetuning, to come in extratests. Opening as draft as I haven't began writing those tests.

@@ -11,17 +11,26 @@
#' used to filter the predicted values before processing. This tibble should
#' only have columns for each tuning parameter identifier (e.g. `"my_param"`
#' if `tune("my_param")` was used).
#' @param type One of `"long"` (the default) or `"wide"`. When `type = "long"`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm conflicted on the name and values for this argument. Very much open to suggestions. :)

Copy link
Member

Choose a reason for hiding this comment

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

I think that a logical called pivot_wider is good. It implies that it is already long.

Copy link
Member

Choose a reason for hiding this comment

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

Just to check, we decided that it's unlikely that we'll ever deviate from something binary? No other forms of "wide" metrics anticipated?

#' output has columns `.metric` and one of `.estimate` or `mean`.
#' `.estimate`/`mean` gives the values for the `.metric`. When `type = "wide"`,
#' each metric has its own column and the `n` and `std_err` columns are removed,
#' if they exist.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't have strong opinions here and the original implementation in #689 had the same behavior, so I did it this way, but if we wanted we could have columns like rmse, rmse_n, rmse_std_err.

Copy link
Member

Choose a reason for hiding this comment

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

I think excluding them is fine; we can add them later if someone asks for them.

if (inherits(x, "last_fit")) {
return(x$.metrics[[1]])
res <- x$.metrics[[1]]
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not stoked about this design pattern.😞 But wasn't clear to me that there's a super clean way to write this.

@simonpcouch simonpcouch mentioned this pull request Jan 31, 2024
@simonpcouch
Copy link
Contributor Author

finetune has its own collect_metrics() methods, so this PR and its tests can function relatively independently of similar changes that would happen in finetune and a paired extratests PR.

@simonpcouch
Copy link
Contributor Author

Ah, I had forgotten that collect_metrics.tune_race() calls NextMethod(). Just added survival tests. :) tidymodels/extratests@abaa263

Copy link
Member

@topepo topepo left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks!

@@ -11,17 +11,26 @@
#' used to filter the predicted values before processing. This tibble should
#' only have columns for each tuning parameter identifier (e.g. `"my_param"`
#' if `tune("my_param")` was used).
#' @param type One of `"long"` (the default) or `"wide"`. When `type = "long"`,
Copy link
Member

Choose a reason for hiding this comment

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

Just to check, we decided that it's unlikely that we'll ever deviate from something binary? No other forms of "wide" metrics anticipated?

@topepo
Copy link
Member

topepo commented Feb 1, 2024

Just to check, we decided that it's unlikely that we'll ever deviate from something binary? No other forms of "wide" metrics anticipated?

I've thought about it some more and I don't think that we will have more ways of pivoting (in tune, at least).

characterize might. It is conceivable that characterize would have up to three options for pivoting but I think that its API would be consistent with the logical/binary argument ☝️

@simonpcouch
Copy link
Contributor Author

The only other form of "wide" or "long" I could imagine is one a la pivot_longer(usual_output, cols = tuning_parameters), where we end up with a column "parameter" and a column "value." I'm not sure in what situations that'd be useful as a pattern.

@simonpcouch simonpcouch merged commit a6fde78 into main Feb 12, 2024
9 checks passed
@simonpcouch simonpcouch deleted the revisit-689 branch February 12, 2024 14:06
Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants