Skip to content

1258: Remove partly missing multivariate forecasts before scoring - #1280

Draft
nikosbosse wants to merge 3 commits into
mainfrom
issue-1258-multivariate-na-groups
Draft

nikosbosse wants to merge 3 commits into
mainfrom
issue-1258-multivariate-na-groups

Conversation

@nikosbosse

@nikosbosse nikosbosse commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

CLAUDE:

Description

This PR closes #1258.

score() removes rows with NA values after the forecast has been validated. For multivariate forecasts this could remove a part of a joint forecast, which was then scored with fewer dimensions, or split one joint forecast into several (a single missing sample turned a two-dimensional forecast into two one-dimensional "energy scores").

score() for multivariate sample and multivariate point forecasts now checks, after rows with NA values have been removed, whether each multivariate forecast is still complete: no forecast unit may have been lost, and for sample forecasts every remaining sample id must be available for every forecast unit. Forecasts that are incomplete are removed entirely, with a warning that says how many were removed and names their .mv_group_id. If no forecast is left, score() errors.

Not affected:

  • Forecasts that are missing entirely (for example rows with observations but no predictions, as in the example data) are dropped silently as before.
  • A forecast in which the same sample is missing for all forecast units is still complete and is scored with one sample less, as before.

Design choice: if a sample is missing for only some forecast units, the whole joint forecast is removed. Removing that sample id from all forecast units would keep more data, but would silently score the forecast with fewer samples than supplied; I kept the more conservative rule.

One existing test changed: "score() preserves scale column for multivariate forecasts" applied sqrt() to the example data, which contain a negative observation. The resulting NaN made 9 joint forecasts incomplete on the sqrt scale, and the test passed only because they were scored on the remaining three locations. The test now uses sqrt(pmax(x, 0)).

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. Full test suite: 0 failures, 1059 passes.
  • I have added or updated unit tests where necessary. New tests for sample forecasts (missing sample, missing observation, different samples missing per location, nothing left, and the two unaffected cases) and point forecasts. I ran them against the unfixed code first, where they fail.
  • I have updated the documentation if required. The new internal helper is documented.
  • I have built the package locally and run rebuilt docs using roxygen2. The new Rd file was generated with roxygen2; NAMESPACE is unchanged.
  • My code follows the established coding standards and I have run lintr::lint_package() to check for style issues introduced by my changes. Linted the changed files, no lints.
  • 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.

Adversarial review

An independent agent reviewed the first version of this PR. It confirmed that every remaining score equals the score of that forecast scored alone, that score() on the example data and all vignette outputs are identical to main, and that the edit to the existing transform test is justified (the original test passes on main only because nine incomplete forecasts were scored on three of four locations).

Addressed:

  • The first version removed every forecast with any NA row, including a forecast in which the same sample is missing everywhere, which is still complete. Completeness is now judged after NA removal.
  • The check ran before validation and degraded one error message. It is now a single helper that runs after validation.
  • The warning now names the affected .mv_group_id values.
  • The regular expression of one test was shortened so that line wrapping cannot break it.

🤖 Generated with Claude Code

nikosbosse and others added 2 commits November 10, 2026 23:29
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.19%. Comparing base (779d7d6) to head (58182bb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1280      +/-   ##
==========================================
+ Coverage   99.18%   99.19%   +0.01%     
==========================================
  Files          41       41              
  Lines        2331     2364      +33     
==========================================
+ Hits         2312     2345      +33     
  Misses         19       19              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A multivariate forecast is now removed only if it lost a forecast unit or
if its remaining samples are not available for all forecast units. One
helper, called after validation, replaces the two previous ones.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

NA values silently split or shrink multivariate groups in score()

1 participant