feat: Update NPResult to contain the posterior and predictions#224
Merged
feat: Update NPResult to contain the posterior and predictions#224
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the NPResult structure to contain pre-calculated Posterior probabilities and optional NPPredictions, improving efficiency by calculating posterior probabilities once during initialization rather than repeatedly when needed.
- Adds
posteriorandpredictionsfields toNPResult, calculated during initialization - Changes
NPResult::new()to returnResult<Self>to handle potential posterior calculation failures - Introduces
calculate_predictions()method to lazily compute and store predictions - Updates parameter passing from owned
Thetato borrowed&Thetafor efficiency
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/structs/theta.rs | Adds write_with_weights() method to write theta with corresponding weights to CSV |
| src/routines/output/predictions.rs | Changes parameter from owned Theta to borrowed reference for efficiency |
| src/routines/output/mod.rs | Adds posterior and predictions fields to NPResult, implements calculate_predictions(), and updates methods to use cached posterior |
| src/bestdose/predictions.rs | Updates call to NPPredictions::calculate() with borrowed theta reference |
| src/algorithms/postprob.rs | Changes into_npresult() signature to return Result<NPResult<E>> |
| src/algorithms/npod.rs | Changes into_npresult() signature to return Result<NPResult<E>> |
| src/algorithms/npag.rs | Changes into_npresult() signature to return Result<NPResult<E>> |
| src/algorithms/mod.rs | Updates trait definition for into_npresult() to return Result and propagates error in fit() |
| examples/vanco_sde/main.rs | Makes result mutable to support new write_outputs() signature |
| examples/two_eq_lag/main.rs | Makes result mutable to support new write_outputs() signature |
| examples/theophylline/main.rs | Makes result mutable to support new write_outputs() signature |
| examples/new_iov/main.rs | Makes result mutable to support new write_outputs() signature |
| examples/neely/main.rs | Makes result mutable to support new write_outputs() signature |
| examples/meta/main.rs | Makes result mutable to support new write_outputs() signature |
| examples/iov/main.rs | Makes result mutable to support new write_outputs() signature |
| examples/drusano/main.rs | Makes result mutable and handles error from into_npresult() |
| examples/bimodal_ke/main.rs | Makes result mutable to support new write_outputs() signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
| Branch | outputs-outputs-outputs |
| Testbed | rust-moan |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result seconds (s) (Result Δ%) | Upper Boundary seconds (s) (Limit %) |
|---|---|---|---|
| bimodal_ke_npag | 📈 view plot 🚷 view threshold | 25.20 s(+0.07%)Baseline: 25.18 s | 26.40 s (95.47%) |
| bimodal_ke_npod | 📈 view plot 🚷 view threshold | 10.45 s(-0.24%)Baseline: 10.47 s | 10.68 s (97.86%) |
| bimodal_ke_postprob | 📈 view plot 🚷 view threshold | 3.47 s(-0.12%)Baseline: 3.47 s | 3.54 s (97.95%) |
* some methods needed in hermes * clean
Siel
approved these changes
Nov 17, 2025
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.
No description provided.