`impute_worst_score()` imputes the maximum of each metric separately, which is not the worst score for several metrics

Open
#1,263 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
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
r
Domain
data

Research direction

Start with R/impute-missing-scores.R and trace how impute_worst_score() selects and fills metric values. Read the “Handling missing forecasts” vignette to understand the documented penalty, then check how the imputed WIS components and coverage and bias values should behave together. Done means imputed rows represent a consistent worst forecast and the documented behavior matches the implementation.

Written by the indexing model from the issue text.

Description

CLAUDE: impute_worst_score() gives every metric its maximum across models, separately per metric. For several default metrics the maximum is not "worst", and the imputed scores of one forecast are no longer consistent with each other.

library(scoringutils)
scores <- score(as_forecast_quantile(example_quantile))
w <- impute_missing_scores(scores, impute_worst_score())
imp <- w[(.imputed)]

max(abs(imp$wis - (imp$overprediction + imp$underprediction + imp$dispersion)))
#> 77582.39      (for original rows: about 6e-11)
table(imp$interval_coverage_50)
#>   0   1
#>  33 104       # missing forecasts are mostly counted as covered
range(imp$bias)
#> -0.9  1.0     # the worst bias is the largest absolute value, not the maximum
class(w$interval_coverage_50)
#> "integer"     # was "logical"
  • interval_coverage_*: the maximum means "covered".
  • bias: signed; the maximum can even be negative.
  • WIS components: maximised separately, so wis no longer equals their sum, which matters for plot_wis().

The vignette "Handling missing forecasts" says this strategy penalises models most heavily, which is not true for these metrics.

Location: R/impute-missing-scores.R.

Suggested fix: copy all metrics from the row with the worst value of one primary metric (e.g. wis, or the first metric), or restrict the strategy to named loss metrics. At a minimum, document that "worst" means "maximum" and warn for coverage and bias columns.

Found during a full review of the package (version 2.3.0.9000, main at 779d7d68).

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.