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

Issue #846 - Implement scoring for ordinal forecasts #977

Merged
merged 12 commits into from
Dec 9, 2024

Conversation

nikosbosse
Copy link
Contributor

@nikosbosse nikosbosse commented Dec 3, 2024

Description

This PR closes #846.

  • implements a new class, forecast_ordinal
  • implements the log score and the ranked probability score for ordinal forecasts

The PR should probably have a few more tests at least for the RPS. @nickreich @elray1 do you happen to have a validated version/example somewhere that we can use?

I also haven't implemented the PIT yet, but I think that's a separate part of the codebase anyway (get_pit_histogram).

There is a small change in the way a vignette is run conditional on ggidst being present that you can probably just ignore. Not sure why it worked before... See more info here: #917.

Checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have included the target issue or issues in the PR title as follows: issue-number: PR title
  • I have tested my changes locally.
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required.
  • I have built the package locally and run rebuilt docs using roxygen2.
  • My code follows the established coding standards and I have run lintr::lint_package() to check for style issues introduced by my changes.
  • I have added a news item linked to this PR.
  • I have reviewed CI checks for this PR and addressed them as far as I am able.

@nikosbosse nikosbosse marked this pull request as ready for review December 3, 2024 13:49
@elray1
Copy link
Collaborator

elray1 commented Dec 3, 2024

Thanks for putting this together! Quick response to your question about existing implementations of RPS: I don't know of any formal, well-tested implementations. The best I've put together is a quick proof of concept.

@nikosbosse
Copy link
Contributor Author

Ah just realised that scoringRules has the RPS - maybe we should use that https://github.com/FK83/scoringRules/blob/master/R/rps.R

@nikosbosse
Copy link
Contributor Author

@elray1 updated the code and edited unit tests for the rps. It now uses the scoringRules version. I think/hope I got the logic for reordering the columns correct, but would appreciate a second pair of eyes

R/metrics-ordinal.R Outdated Show resolved Hide resolved
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 good to me. I'm not totally across the rps so it might be a good idea for someone else to check

Copy link
Collaborator

@elray1 elray1 left a comment

Choose a reason for hiding this comment

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

I read through the code and tried out a few worked examples. The functionality all looks good/correct. I had a few comments on documentation and example setup, as well as some suggestions for opportunities for refactoring/sharing code between the nominal and ordinal forecast classes which I'm perfectly happy if you ignore.

R/class-forecast-ordinal.R Outdated Show resolved Hide resolved
R/metrics-nominal.R Outdated Show resolved Hide resolved
R/metrics-ordinal.R Show resolved Hide resolved
R/metrics-ordinal.R Outdated Show resolved Hide resolved
R/metrics-ordinal.R Outdated Show resolved Hide resolved
R/metrics-ordinal.R Outdated Show resolved Hide resolved
R/metrics-ordinal.R Outdated Show resolved Hide resolved
R/metrics-ordinal.R Outdated Show resolved Hide resolved
@nikosbosse
Copy link
Contributor Author

Most recent updates:

  • refactored assert_input_nominal and assert_input_ordinal to use a common assert_input_categorical
  • replaced logs_ordinal and logs_nominal with a common logs_categorical and added a deprecation warning.
  • accepted suggestions from @elray1 related to docs

@seabbs seabbs requested a review from elray1 December 9, 2024 11:45
Copy link
Collaborator

@elray1 elray1 left a comment

Choose a reason for hiding this comment

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

lgtm

@nikosbosse nikosbosse merged commit e73e2b8 into main Dec 9, 2024
9 checks passed
@nikosbosse nikosbosse deleted the forecast-ordinal branch December 9, 2024 11:57
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.

evaluation for ordinal predictions
3 participants