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 more tests for score() #502

Closed
nikosbosse opened this issue Nov 24, 2023 · 7 comments · Fixed by #924
Closed

Add more tests for score() #502

nikosbosse opened this issue Nov 24, 2023 · 7 comments · Fixed by #924
Labels
implementation-ready This is ready for implementation package improvement

Comments

@nikosbosse
Copy link
Contributor

nikosbosse commented Nov 24, 2023

It would be good to add a few more tests for score().

Sample case:
What happens if you only have a single sample?

Quantile case:
what happens if you only

  • submit the median
  • a single quantile that is not the median
  • an asymmetric interval
@nikosbosse nikosbosse changed the title Add more tests for score() for the quantile case Add more tests for score() Nov 24, 2023
@nikosbosse nikosbosse added this to the scoringutils 2.0.0 milestone Nov 29, 2023
@nikosbosse nikosbosse added the implementation-ready This is ready for implementation label Dec 5, 2023
@seabbs
Copy link
Contributor

seabbs commented Feb 28, 2024

Do we have any progress on this? Maybe we could update to a checklist to make this more modular

@seabbs
Copy link
Contributor

seabbs commented Mar 18, 2024

Anyone keen to chip in here on some infra (maybe @jamesmbaazam :))

@nikosbosse
Copy link
Contributor Author

In the process of adding some tests.

The following leads to a lot of warnings which need to be cleaned up eventually. Some of them are fine and expected, others like the "Column 'dispersion' does not exist to remove" or "! Function execution failed, returning NULL. Error: argument is of length zero." are a bit opaque.

# only one quantile that is not the median 
  onlyonequantile <- example_quantile[quantile_level == 0.3] %>%
    as_forecast()

  expect_error(
    score(onlyonequantile, metrics = metrics_quantile(
      exclude = c("interval_coverage_50", "interval_coverage_90")
    )),
    ""
  )
  expect_warning(
    score(onlyonequantile, metrics = metrics_quantile(
      exclude = c("interval_coverage_50", "interval_coverage_90")
    )),
    "Function execution failed, returning NULL. Error: object 'upper' not found."
  )

1: ! Function execution failed, returning NULL. Error: object 'upper' not found.
2: In `[.data.table`(forecast, , `:=`((metric_name), do.call(run_safely,  ... :
  Column 'wis' does not exist to remove
3: ! Function execution failed, returning NULL. Error: object 'upper' not found.
4: In `[.data.table`(forecast, , `:=`((metric_name), do.call(run_safely,  ... :
  Column 'overprediction' does not exist to remove
5: ! Function execution failed, returning NULL. Error: object 'upper' not found.
6: In `[.data.table`(forecast, , `:=`((metric_name), do.call(run_safely,  ... :
  Column 'underprediction' does not exist to remove
7: ! Function execution failed, returning NULL. Error: object 'upper' not found.
8: In `[.data.table`(forecast, , `:=`((metric_name), do.call(run_safely,  ... :
  Column 'dispersion' does not exist to remove
9: In min(quantile_level[quantile_level > 0.5]) :
  no non-missing arguments to min; returning Inf
10: ! Function execution failed, returning NULL. Error: argument is of length zero.
11: In `[.data.table`(forecast, , `:=`((metric_name), do.call(run_safely,  ... :
  Column 'bias' does not exist to remove
12: ✖ To compute interval coverage deviation, all quantiles must form central symmetric prediction intervals.
ℹ Missing quantiles: 0.7. Returning NA.
13: ✖ In order to compute the absolute error of the median, "0.5" must be among the quantiles given.
ℹ Returning "NA".

Similar for the case of one asymmetric quantile:

 # one asymmetric interval
  oneasymmetric <- example_quantile[quantile_level %in% c(0.2, 0.6)] %>%
    as_forecast()

  expect_warning(
    expect_warning(
      suppressMessages(
        score(onlyonequantile, metrics = metrics_quantile(
          exclude = c("interval_coverage_50", "interval_coverage_90")
        ))
      ),
      "To compute interval coverage deviation, all quantiles must form central symmetric prediction intervals."
    ),
    'In order to compute the absolute error of the median'
  )

@nikosbosse
Copy link
Contributor Author

I spun up new issues, #800 and #801, that came up when trying to address this. Once these are addressed I think it makes sense to circle back and include the two tests I mentioned in the last comment.

@nikosbosse
Copy link
Contributor Author

The "Column 'dispersion' does not exist to remove" errors are addressed in #801.

@jamesmbaazam
Copy link
Contributor

Anyone keen to chip in here on some infra (maybe @jamesmbaazam :))

Sorry, I missed this notification.

nikosbosse added a commit that referenced this issue May 18, 2024
@nikosbosse
Copy link
Contributor Author

Update: some things disappeared, but this has still a few errors/warnings:

onlyonequantile <- example_quantile[quantile_level == 0.3] |>
  as_forecast()

score(onlyonequantile, metrics = metrics_quantile(
  exclude = c("interval_coverage_50", "interval_coverage_90")
))

Working on them :)

seabbs added a commit that referenced this issue Sep 30, 2024
* improve error messages, replace warnings with errors

* fix tests

* add more tests for `score()`

* fix failing test

---------

Co-authored-by: Sam Abbott <contact@samabbott.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implementation-ready This is ready for implementation package improvement
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants