stan-dev / loo

loo R package for approximate leave-one-out cross-validation (LOO-CV) and Pareto smoothed importance sampling (PSIS)
https://mc-stan.org/loo
Other
150 stars 34 forks source link

pointwise() convenience function for extracting pointwise estimates #241

Closed jgabry closed 7 months ago

jgabry commented 8 months ago

Closes #126

I ended up wanting this to make some code look nicer and it was very easy to implement, so I made a PR.

pointwise(loo_object, "elpd_loo") # returns vector of pointwise elpd_loo estimates
pointwise(loo_object, "p_loo") # returns vector of pointwise p_loo estimates
# etc. 

This works not only for loo() but also for loo_subsample(), loo_moment_match(), etc.

codecov-commenter commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (0d53b04) 93.00% compared to head (4e7c1bd) 93.03%.

:exclamation: Current head 4e7c1bd differs from pull request most recent head 5833dbe. Consider uploading reports for the commit 5833dbe to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #241 +/- ## ========================================== + Coverage 93.00% 93.03% +0.02% ========================================== Files 30 31 +1 Lines 2788 2800 +12 ========================================== + Hits 2593 2605 +12 Misses 195 195 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jgabry commented 7 months ago

@avehtari This is super simple, so you don't need to spend much (or any) time looking at this, but just wanted to check if you're ok with adding this little convenience function. I think it's ready to merge if it's ok with you. I'm starting to prepare the release.