Skip to content

Review #363 (7/19): Results no longer inherit the loo classes; error for subsampled loo - #434

Draft
florence-bockting wants to merge 4 commits into
fix/pred-measure-argsfrom
fix/pred-measure-classes
Draft

florence-bockting wants to merge 4 commits into
fix/pred-measure-argsfrom
fix/pred-measure-classes

Conversation

@florence-bockting

@florence-bockting florence-bockting commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR 7/19 for the review of #363. This PR stacks on #430.

Results no longer inherit the loo, psis_loo and kfold classes

Review comments: main review ("What if we stop inheriting …"), r4544867674

Implementation:

  • .add_attributes() sets the class to c("<source>_pred_measure", "pred_measure") (R/pred_measure-compute.R). It still copies the other attributes of the loo or kfold object (e.g. K, folds).
  • measure_*() results have the class "measure" only (R/pred_measure-builtin.R).
  • .model_compare_inputs() errors for a "measure" object: "Cannot compare 'measure' objects. Use a *_pred_measure() function for each model." (R/model_compare.R). Before, model_compare(m1, m2) failed with "dim(X) must have a positive length". The check covers model_compare(m1, m2), model_compare(list(m1, m2)) and a mix with a loo object. The message does not name model_compare(), because the deprecated loo_compare() also calls this function.
  • The comment in model_compare.default() about the order of the is.loo() check is removed. It is no longer true.
  • The @return of loo_pred_measure() no longer lists "loo" or other inherited classes.

Effects:

  • loo_model_weights() no longer accepts a loo_pred_measure result.
  • plot() for Pareto k no longer works on a loo_pred_measure result. print(x, plot_k = TRUE), pareto_k_values() and pareto_k_table() still work.

Tests:

  • test_pred_measure.R: the is.loo() and is.psis_loo() expectations are replaced by one test. It checks the exact classes of results from loo_pred_measure() (three input forms), kfold_pred_measure() and insample_pred_measure(). On the old code the loo and kfold expectations fail (4 of 5).
  • test_compare.R: a new test checks the error for the three call forms above. All three fail on the old code. The data has 32 observations, like the waic object w1. Thus the mixed call fails on the measure object, not on the number of observations.

loo_pred_measure() errors for subsampled loo objects

Review comment: r4544589870

Implementation: do_pred_measure() errors when loo is a psis_loo_ss object (R/pred_measure-compute.R): "loo_pred_measure() does not support subsampled objects. Use loo(), or compare the <psis_loo_ss> objects with model_compare()." The check runs before the psis_object check. Thus a subsampled object without a psis_object does not get the save_psis = TRUE hint.

Full support needs new estimators for the measures other than elpd.

Tests: test_pred_measure.R gets a test with as.psis_loo_ss(res$loo). On the old code loo_pred_measure() returns a result with no error, so the test fails.

Test runs

The tests that match pred_measure|compare|print|model_weighting|subsampling_cases|deprecated pass.

This PR was assisted by use of LLM.

@codecov-commenter

codecov-commenter commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.48%. Comparing base (03dd172) to head (d914616).

Additional details and impacted files
@@                    Coverage Diff                    @@
##           fix/pred-measure-args     #434      +/-   ##
=========================================================
+ Coverage                  92.44%   92.48%   +0.03%     
=========================================================
  Files                         38       38              
  Lines                       4712     4710       -2     
=========================================================
  Hits                        4356     4356              
+ Misses                       356      354       -2     

☔ 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.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if d914616 is merged into fix/pred-measure-args:

Status Name Current Incoming Interval
✔️ loo_matrix 1.33s 1.34s [-0.52%, +1.62%]
✔️ loo_function 1.16s 1.16s [-1.31%, +1.05%]

Further explanation regarding interpretation and methodology can be found in the documentation.

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.

2 participants