Repository navigation
1257: Match multivariate samples by sample_id - #1279
Draft
nikosbosse wants to merge 3 commits into
Draft
nikosbosse wants to merge 3 commits into
nikosbosse wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1279 +/- ##
=======================================
Coverage 99.18% 99.19%
=======================================
Files 41 41
Lines 2331 2347 +16
=======================================
+ Hits 2312 2328 +16
Misses 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CLAUDE:
Description
This PR closes #1257.
score()for multivariate sample forecasts built the joint samples by row position: the j-th row of each forecast in a group became the j-th joint sample, andsample_idwas never used. The same data in a different row order therefore gave different (wrong) energy and variogram scores, without a warning. The example data only score correctly because they happen to be sorted.Changes:
score.forecast_multivariate_sample()orders the samples of each forecast bysample_idbefore building the matrices, so samples with the same id are matched across the forecasts of a group. The order of the rows in the output is unchanged.assert_forecast.forecast_multivariate_sample()now errors if the forecasts of a group do not have the same sample ids, since joint samples are then undefined. Sample ids may still differ between groups.Behaviour change to be aware of: data in which the forecasts of a group use different sample ids (for example ids that are unique across the whole data set) were accepted before and now raise an error. Their scores depended on row order before.
Checklist
scoringRules::es_sample()on ordered and shuffled data (also for the example data), and mismatching sample ids within a group raise an error. I ran them against the unfixed code first, where 6 expectations fail.lintr::lint_package()to check for style issues introduced by my changes. Linted the changed files, no lints.Adversarial review
An independent agent reviewed the PR. On 200 random data sets (1-3 models, 2-4 locations, 5-20 samples, integer, character, factor and non-contiguous ids, shuffled rows, keyed tables) the branch matched
scoringRules::es_sample()/vs_sample()every time, wheremainmismatched all 200. Validation time on 1e6 rows is unchanged, and typical operations on a valid object (head(), filtering) are not newly rejected.Addressed:
sample_idcould change the order of the output rows. Samples are now ordered within each forecast, which keeps the output order (with a test).Not addressed here: missing predictions. Validation runs before rows with
NAvalues are removed, so if different samples are missing in different forecasts of a group, the remaining samples are still paired by position. That is the subject of #1258 / PR #1280, which removes such incomplete forecasts before scoring. The two PRs touch the same function, so the second one to merge needsmainmerged in.🤖 Generated with Claude Code