epiforecasts / scoringutils

Utilities for Scoring and Assessing Predictions
https://epiforecasts.io/scoringutils/
Other
48 stars 21 forks source link

Discussion: workflow for creating and validating forecast objects #472

Closed nikosbosse closed 11 months ago

nikosbosse commented 11 months ago

This issue collects all questions surrounding the workflow to create and validate forecast objects.

Overall questions

Old behaviour (before the update)

Previously, we had a function check_forecasts() that

There were several potential worklflows:

New behaviour

What functions should exist?

Advanced R suggests that every class should have

  • A low-level constructor, new_myclass(), that efficiently creates new objects with the correct structure.
  • A validator, validate_myclass(), that performs more computationally expensive checks to ensure that the object has correct values.
  • A user-friendly helper, myclass(), that provides a convenient way for others to create objects of your class.

Usually,

Other things that I've seen:

Proposal:

(this now assumes that the classes are going to be called forecast_something, see #473

Image

Output diagnostics

The proposal above currently does not capture everything the old check_forecasts() did. In particular, it doesn't provide output diagnostics.

We could likely get much of the desired behaviour by creating a print method for forecast_binary etc. This print method could then use the stored attributes to return something like

dataframe

This is a forecast of type `binary`. 

The unit of a single forecast is defined by 
[1] "location" "target_end_date" "target_type" 
[4] "location_name" "forecast_date" "model" 
[7] "horizon"

And then when the forecast is summarised or if other attributes are added, these could be added to the output as well

The output has been summarised by 
[1] "model"

This doesn't give us everything the old check_forecasts() had. E.g. it doesn't give us a list (which is probably easier to access than the attributes). It also doesn't give us the unique_values component that the old check_forecasts() had. I did like that, but it can also just be an extra function.

nikosbosse commented 11 months ago

@seabbs @sbfnk @Bisaloo

nikosbosse commented 11 months ago

Decisions taken:

we have

Illustration:

Image

as_forecast isn't fully generic, i.e. hard for other users to work with who would want to create new classes. But I think that's fine for now / don't have a good idea for how to make it better in a non-crazy way.

Every class gets a print method that provides useful information on the output.

Please reopen if you disagree with anything.