Adding pred_measure feature#363
Conversation
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 884df6e is merged into loo-v3.0.0:
|
|
Linking here to Issue #179 as it seems to be about loo scores. We should see whether it is still relevant and can be implemented within loo refactoring.
|
|
There is an open issue requesting a subset() method for psis objects #343 and an (unrelated) open PR #110. Might be worth considering whether we can address this as well in this refactoring PR. If yes, we should
Moved this to PR #379 |
pred_measure feature
404656a to
562b141
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## loo-v3.0.0 #363 +/- ##
==============================================
- Coverage 92.70% 89.45% -3.26%
==============================================
Files 31 35 +4
Lines 3029 4124 +1095
==============================================
+ Hits 2808 3689 +881
- Misses 221 435 +214 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #281
Summary
Adds a unified predictive performance measures API on top of
loo-v3.0.0. Density scores, scoring rules, and point-prediction metrics can be computed under in-sample, PSIS-LOO, k-fold, and holdout evaluation via*_pred_measure().Design log:
developer-notes.md(edit:developer-notes.Rmd)Issues addressed
This PR consolidates work that was tracked across several related issues:
ypreddraw matrix (measure_rps(),measure_srps())loo_pred_measure()accepts a pre-computedpsis_object(or extracts one from alooresult withsave_psis = TRUE)measure_r2()as a built-in*_pred_measure()—loo_compareintegration still outstanding (see Known limitations)How to navigate this PR
This is a large PR. These documents explain design, scope, and current status:
developer-notes.md:central reference: status, open tasks, design decisions, numerical comparisons
overview-measures.Rmd: supported scores and metrics, with mathematical definitionspred-measure-workflow.Rmd: conceptual introduction and end-to-end workflow examplesmigration-guide.Rmd: mapping from deprecated functions to the new APIWhat's new
insample_pred_measure(),loo_pred_measure(),kfold_pred_measure(),test_pred_measure(),pred_measure()measure_*()+supported_measures_list()(incl.r2, classification metrics, Brier, MAE/MSE/RMSE, ELPD/IC)measure_rps()/measure_srps()— singleypredmatrix, PWM/ECDF estimator; covers continuous and ordered categorical outcomes (CRPS/RPS and scaled variants in the new API)measurepsis_objector reuse weights from a priorloo_pred_measure()result viapredperfpred_measureobjects (incl. Pareto-k-hat for LOO)migration-guidevignette + website-onlyoverview-measuresandpred-measure-workflowarticles.Rdsfixtures, pkgdown vignette-data generation stepDeprecations (implementations retained)
Existing functions are deprecated but still work with their current APIs:
elpd()measure_elpd()/*_pred_measure()crps(),scrps()(x,x2)measure_rps(),measure_srps()(ypred)loo_crps(),loo_scrps()loo_pred_measure(..., measure = "rps" | "srps")loo_predictive_metric()loo_pred_measure()In
*_pred_measure(),elpdis computed automatically whenylpis supplied; requestmeasure = "ic"separately for the information criterion.The new RPS functions use a different estimator (one draw matrix, PWM) than deprecated CRPS (two draw matrices, permutation). Results are highly correlated but not identical — see the comparison section and figures in
developer-notes.Rmd. Comparison tests are intests/testthat/test_crps.R.Dependencies
Vignettes, test-data generation, and pkgdown CI install brms from GitHub
master(paul-buerkner/brms), because k-fold support for categorical / multinomial models (brms#1890, fixing brms#1889) is not yet on CRAN. Once a CRAN release includes that fix, the GitHub pin can be dropped.Known limitations
group_idsgrouping not yet implementedloo_compareintegration still outstandingSee
developer-notes.Rmdfor open design questions andremaining tasks.
Acknowledgements
This work builds on an initial prototype of the
pred_measurefeature implemented by @VisruthSK (see VisruthSK/loo-sandbox) under guidance from @jgabry.Test plan
devtools::test()anddevtools::check()passdevtools::test(): 1 failure — unrelatedtest_psislw.Rsnapshot drift (Warning in psislw()→Warning:)R CMD check: 1 error —kfold_pred_measure()roxygen example usesmeasure = "rmse"withoutmupredtest_deprecated_measures.R)test_crps.R; not re-diffed againstloo-v3.0.0branch)test_crps.R, 32 tests)*_pred_measure()examples run (migration guide + workflow vignette; rendered locally withNOT_CRAN=true)brms(workflow + migration-guide articles render; fullpkgdown::build_site()not verified locally — existingdocs/blocks build)