scoringutils icon indicating copy to clipboard operation
scoringutils copied to clipboard

Add check to `validate_forecast()` that predictions must not decrease with quantile

Open nikosbosse opened this issue 1 year ago • 3 comments

Update: Current plan is to:

  • write a helper function to check that
  • enforce it in bias_quantile() as it's needed there
  • check + warn in validate_forecast().

This is currently implemented in bias_quantile_single_vector()

order <- order(quantile)
predicted <- predicted[order]
if (!all(diff(predicted) >= 0)) {
    stop("Predictions must not be decreasing with increasing quantile level")
  }

In principle, we could add this to assert_input_quantile(). Since assert_input_quantile() is called by every metric, it might add a bit of overhead, but I'm unsure how much. If we're concerned about overhead, we could also add it to validate_forecast() once. Or not check at all..

another code snipped I had lying around somewhere:

booster_data |>
  arrange(model, target, submission_date, target_end_date, scale, quantile_level) |>
  group_by(model, target, submission_date, target_end_date, scale) |>
  mutate(value = predicted - lag(predicted)) |>
  filter(value < 0 )

nikosbosse avatar Nov 10 '23 09:11 nikosbosse

Maybe it would be nice to not have this as a check, but instead as some kind of helper function to check the plausibility of a forecast?

nikosbosse avatar Nov 23 '23 09:11 nikosbosse

We could add this as a warning/messsage to validate_forecast vs having it error?

seabbs avatar Nov 27 '23 13:11 seabbs

Happy with that idea. So plan would be to

  • write a helper function to check that
  • enforce it in bias_quantile() as it's needed there
  • check + warn in validate_forecast().

nikosbosse avatar Nov 29 '23 14:11 nikosbosse