Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log probability interface for post-inference analysis (#438)
* extended methods for `logprior`, `loglikelihood`, `logposterior` for chains. * accept Github Actions. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * typed `AbstractChains`; removed Array inputs. * re-formatting. * removed comments to pass formatting test. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * 1. removed the import statements in `lop.jl`; 2. removed the DynamicPPL. namespace declarations of the functions; 3. used Distributions.loglikelihood (instead of `StatsBase.loglikelihood`); 4. moved the tests to test/logp.jl and included them in test/runtests.jl. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * modified src/logp.jl; added test/logp.jl * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Modified Docstrings; Changed names; Modified methods following Tor's suggestions. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * renamed `chain_logprior`,`chain_loglikelihood',`chain_logposterior' to `logprior`,`loglikelihood',`logposterior' . * added `include("logdensityfunction.jl")` to `DynamicPPL.jl` * formatted `test/logp.jl`. * Update test/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * formatted `scr/logp.jl`. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * formatted `scr/logp.jl`. * Removed comments. * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update src/logp.jl Co-authored-by: David Widmann <[email protected]> * Update test/logp.jl Co-authored-by: David Widmann <[email protected]> * removed redundant methods (NamedTuples and Array inputs). * added REPL examples to docstrings. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * added `start_idx` into `src/logp.jl`; rewrite `test/logp.jl` using `map-do`; added `MCMCChains` & `StableRNGs` to `DynamicPPL.jl`. * added `start_idx` to the 3 methods. * Reduced chainn size in the docstrings example. * applied formatting. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * upated signatures in docstrings. * applied formatting. * formatted again. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix doctests setup * Update docs/make.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/runtests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * applied formatting. * Formatting. * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/logp.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fix doc tests again. * Fixed formatting. * Merged `logp.jl` into `model.jl` * CompatHelper: bump compat for Turing to 0.24 for package turing, (keep existing compat) (#448) * CompatHelper: bump compat for Turing to 0.24 for package turing, (keep existing compat) * Update test/turing/Project.toml Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Tor Erlend Fjelde <[email protected]> * CompatHelper: bump compat for Turing to 0.23 for package turing, (keep existing compat) (#439) * CompatHelper: bump compat for Turing to 0.23 for package turing, (keep existing compat) * Update test/turing/Project.toml Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Hong Ge <[email protected]> * Fixed obsolete `TArray` reference. * Fixed incorrect code. * More bugfixes in logp tests. * Avoid calling Turing sampler. * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Replace SampleFromPrior with synthetic chain. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Minor bugfix. * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update Project.toml * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update test/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Update src/model.jl Co-authored-by: David Widmann <[email protected]> * Added `logprior_true(model,NamedTuple)' and `loglikelihood_true(model, NamedTuple)' methods; revised test/model.jl accordingly (removed `MCMCChains.get_param()' ). * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fixed missing prefix and imports. * Move tests into convenience functions. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Removed constraints on floating number precision. * Fix type constraint again. * Apply suggestions from code review Co-authored-by: David Widmann <[email protected]> * 1. removed `StableRNGs`; 2. replaced `map(1:N) do i` in test/model.jl by `for i in 1:N`. * Bugfix. * Import TestUtils -- it is not exported by DPPL. * Specialise on model type. * Improve test. * Update src/test_utils.jl * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Tor Erlend Fjelde <[email protected]> Co-authored-by: David Widmann <[email protected]> * Apply suggestions from code review Co-authored-by: David Widmann <[email protected]> * midified the way chain value was extracted in all 3 methods. * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: David Widmann <[email protected]> * Update src/model.jl * Update src/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/utils.jl * rewrote the tests (mainly the way extracting parameter values from chain). * removed BangBang from doctest setup; fixed imcomplete end in test/model.jl. * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fixed a naming bug (argvals_mat_dict) in src/model.jl. * fixed a typo - missing `var_info`. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: David Widmann <[email protected]> * Apply suggestions from code review Co-authored-by: David Widmann <[email protected]> * Explicitly added `using Distributions` in doctests; Accepted suggestion in test/model.jl, tests passed locally. * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * rm unnecessary deps * replace contains with subsumes. * rm redundant deps in docs build script. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fix format. * Replaced `subsumes` by `contains`. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * replaced 'contains' by a new, temporary method 'subsumes_sym', just for testing purpose. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * modified `/test/model.jl`: 1. build a map between model parameter symbol (`s`,`m`) and chain parameter names (which is obtained via `varname_leaves`.) 2. use this naming map to collect sample values from chain and drop into `log_true` for validation. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fixed a mistake in `modify_value_representation`. * fixed `gdemo_default` * assigned `model=gdemo_default`. * src/model.jl: added `DynamicPPL.` to `logprior` and `logjoint`. * commented out `gdemo_d()` as a trial test. * used `Symbol(vn_child)` as keys in `chain_sym_map`. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * explicitly loaded `varname_leaves` and `values_from_chain`. * added `print` statements for temporary diagnosis purpose. * added 'print` statements for temporary diagnostics purpose. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * diagnostics again. * Removed some `print` statements as it's working. * Update test/model.jl Co-authored-by: Hong Ge <[email protected]> * Update test/model.jl Co-authored-by: Hong Ge <[email protected]> * Update test/model.jl Co-authored-by: Hong Ge <[email protected]> * Update test/model.jl Co-authored-by: Hong Ge <[email protected]> * 1. moved helper functions to `test_util.jl`; 2. re-wrote the way `chain_mat` can be generated. * Update test/model.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * formatting. * formatting. * Update utils.jl * Update test_util.jl * Update Project.toml * replaced 'varname_leaves' by 'DynamicPPL.varname_leaves'. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: David Widmann <[email protected]> Co-authored-by: Hong Ge <[email protected]> Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Tor Erlend Fjelde <[email protected]> Co-authored-by: Hong Ge <[email protected]> Co-authored-by: Jose Storopoli <[email protected]>
- Loading branch information
f6f02ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yebai This shouldn't have been merged.