Add helper to complete nominal/ordinal forecasts with omitted zero-probability categories

Open
#1,239 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
r
Domain
data

Research direction

Read the discussion in #608 and inspect forecast_nominal and forecast_ordinal to understand the required forecast format and validation. Then trace how forecast data and factor levels are represented, including how an optional levels argument could apply. Done means an exported helper explicitly adds omitted zero-probability categories for each forecast unit; the issue leaves the standalone helper versus an argument on as_forecast_nominal() unresolved.

Written by the indexing model from the issue text.

Description

enhancement

CLAUDE: Follow-up from #608.

In #608 we agreed on a strict input format for categorical forecasts: every forecast must list every category, including those with probability 0. This is now implemented as forecast_nominal (and forecast_ordinal), and incomplete forecasts fail validation with "Found incomplete forecasts". The thread also agreed on a convenience helper that fills in the omitted zero-probability categories, but it was never built. Users whose models only output the non-zero classes currently have to expand the data themselves.

Proposal

An exported helper, e.g. complete_forecast_nominal(data, levels = NULL), that adds the missing predicted_label levels with predicted = 0 for each forecast unit. The levels come from the factor levels of observed / predicted_label, unless levels is given. The same helper could also handle ordinal forecasts.

Open question

A standalone helper, or a complete = FALSE argument on as_forecast_nominal()? I'd suggest the standalone helper. Filling in categories automatically during validation could hide real data errors (e.g. a misspelt label), so completing the data should be an explicit step.

Dominant language
R
Stars
67
Forks
24
Avg merge
1h 24m
Merged PRs (30d)
2

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from epiforecasts/scoringutils

All issues in epiforecasts/scoringutils

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.