Skip to content

Conversation

@nikosbosse
Copy link
Collaborator

This PR is a first step towards reworking score.scoringutils_quantile(). The work isn't done, but I figured it would be better to keep PR size reasonable.. :)

This PR

  • Creates a first draft for score.scoringutils_quantile() (currently called score.scoringutils_quantile_new()
  • Creates a helper function run_safely() which allows to run functions safely regardless of the arguments passed to it
  • updates metrics_quantile, the default metrics for score.scoringutils_quantile() to include interval_coverage for interval levels 50 and 90.

Left to do:

  • Switch new function to actual score.scoringutils_quantile()
  • Split wis components into their own functions and get rid of special handling of wis() within score.scoringutils_quantile()

Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

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

This looks fine but as discussed on our call last week I don't like the suggested usage of run_safely and tbh am not entirely convinced of the idea of arg passing as you are proposing for score.

Note that this PR is a good example where there is next to no information about what has changed/why it has changed in a way that makes it easy to understand the decision underlying the code changes.

necessary_quantiles <- c((100 - range) / 2, 100 - (100 - range) / 2) / 100
if (!all(necessary_quantiles %in% quantile)) {
rlang::warn(
warning(
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you changing this back?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It errored 🥲 So I made an issue (#415) and switched it back for now. In hindsight I see your point about adding that as context here... Apologies!

lapply(seq_along(metrics), function(i, ...) {
metric_name <- names(metrics[i])
fun <- metrics[[i]]
matching_args <- filter_function_args(fun, args)
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we agreed that run_safely would be used here?

Copy link
Contributor

Choose a reason for hiding this comment

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

or that we wouldn't do this at all

#' @param ... Arguments to pass to `fun`
#' @param fun A function to execute
#' @return The result of `fun` or `NULL` if `fun` errors
#' @export
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want this to be used internally not in the metrics list


if (inherits(result, "try-error")) {
msg <- conditionMessage(attr(result, "condition"))
warning(
Copy link
Contributor

Choose a reason for hiding this comment

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

rlang or base what are you using?

@nikosbosse nikosbosse merged commit f5bb30b into rework-add_coverage() Nov 15, 2023
@nikosbosse nikosbosse deleted the rework-score.quantile() branch November 15, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants