Skip to content

Commit 4522a85

Browse files
Merge pull request #7 from pymc-devs/model-architecture
Add model architecture
2 parents 44a019c + ca0f29e commit 4522a85

File tree

11 files changed

+192
-8
lines changed

11 files changed

+192
-8
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
1212
rev: "v6.0.0"
1313
hooks:
14-
#- id: check-added-large-files
14+
- id: check-added-large-files
1515
- id: check-ast
1616
- id: check-case-conflict
1717
- id: check-json
1818
- id: check-merge-conflict
1919
- id: check-symlinks
2020
- id: check-yaml
21+
exclude: ^mkdocs\.yml$ # otherwise !!python/name:mermaid2.fence_mermaid in .mkdocs.yaml make it fail
2122
- id: debug-statements
2223
- id: detect-private-key
2324
- id: end-of-file-fixer

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<!--- --8<-- [start:description] -->
2-
# PyMC elicito
3-
4-
Learning prior distributions for parameters in a Bayesian model based on expert information.
5-
2+
# PyMC elicito: A Python package for expert prior elicitation using PyMC
63
**Key info :**
74
[![Docs](https://readthedocs.org/projects/pymc-elicito/badge/?version=latest)](https://pymc-elicito.readthedocs.io)
85
[![Main branch: supported Python versions](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fpymc-devs%2Fpymc-elicito%2Fmain%2Fpyproject.toml)](https://github.com/pymc-devs/pymc-elicito/blob/main/pyproject.toml)
@@ -50,10 +47,13 @@ Some suggested options:
5047
and we won't reply to any issues
5148
-->
5249

53-
**Prototype**:
50+
**Prototype**:
5451
This project is just starting up and the code is all prototype.
5552
Pymc-elicito re-implements the Python package [`elicito`](https://github.com/florence-bockting/elicito) using pymc instead of tensorflow(-probability) as dependency.
5653

54+
## Description
55+
**Expert prior elicitation** aims to define prior distributions for parameters within a Bayesian model that accurately incorporate the expectations of a domain expert. The `elicito` computational framework supports the modular implementation of diverse expert prior elicitation methods.
56+
5757
<!--- --8<-- [end:description] -->
5858

5959
Full documentation can be found at:

docs/NAVIGATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ See https://oprypin.github.io/mkdocs-literate-nav/
99
- [Tutorials](tutorials/index.md)
1010
- [Further background](further-background/index.md)
1111
- [Dependency pinning and testing](further-background/dependency-pinning-and-testing.md)
12+
- [Model architecture](further-background/model-architecture.md)
1213
- [Development](development.md)
1314
- [API reference](api/pymc_elicito/)
1415
- [Changelog](changelog.md)
722 KB
Loading

docs/further-background/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ Points we will aim to cover:
1111
- Why it was created
1212
- Help the reader make connections
1313

14-
We will aim to avoid writing instructions or technical descriptions here,
15-
they belong elsewhere.
14+
We will aim to avoid writing instructions or technical descriptions here, they belong elsewhere.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Software Architecture of `elicito`
2+
The core computational workflow of the expert prior elicitation method implemented in `elicito` is based on a simulation-based optimization approach: Given a generative model and a set of initial hyperparameters defining the prior distributions, the model can be run in forward mode to simulate elicited summaries by computing the predefined target quantities and summary statistics. These simulated summaries are then compared with the
3+
expert-elicited summaries obtained during the expert-elicitation stage. An iterative optimization scheme is employed to update the hyperparameters of the parametric prior distributions so as to minimize the discrepancy between simulated and expert-elicited summaries. In other words, the objective is to identify the vector of hyperparameters that yields the closest alignment between simulated and expert-elicited summaries.
4+
5+
```mermaid
6+
flowchart TB
7+
subgraph eliobj["Elicit class (user input)"]
8+
input["Model, Parameters, Targets, \n Network, Initializer, Optimizer, \n Meta-Setting"]
9+
expert_dat["expert elicited summaries"]
10+
end
11+
subgraph initialization["initialization"]
12+
initializer["initializer"]
13+
hyper_parametric("prior parameters")
14+
hyper_deep("weights/biases of DNNs")
15+
end
16+
17+
subgraph subGraph3["priors"]
18+
transformation["transform to constrained space"]
19+
prior["sample from prior in \n unconstrained space"]
20+
end
21+
subgraph model["model"]
22+
generative_model["run generative model \n in forward mode"]
23+
end
24+
subgraph summaries["summaries"]
25+
elicits["elicited summaries"]
26+
summary["target quantities"]
27+
end
28+
subgraph loss["loss"]
29+
total_loss["total loss"]
30+
indiv_loss["individual losses"]
31+
end
32+
subgraph optimization["optimization"]
33+
gradients["gradients"]
34+
end
35+
subgraph training["training"]
36+
subGraph3
37+
prior_samples[/"prior samples"/]
38+
model
39+
model_output[/"model simulations"/]
40+
summaries
41+
simulated_summaries[/"simulated summaries"/]
42+
loss
43+
optimization
44+
check{"convergence \n criterion"}
45+
train_vars[/"trainable variables \n (=hyperparameters)"/]
46+
end
47+
input --> initializer
48+
initializer -- if parametric prior --> hyper_parametric
49+
initializer -- if deep prior --> hyper_deep
50+
hyper_parametric --> train_vars
51+
hyper_deep --> train_vars
52+
train_vars --> prior
53+
expert_dat --> indiv_loss & input
54+
prior --> transformation
55+
transformation --> prior_samples
56+
prior_samples --> generative_model
57+
generative_model --> model_output
58+
model_output --> summary
59+
summary --> elicits
60+
elicits --> simulated_summaries
61+
simulated_summaries --> indiv_loss
62+
indiv_loss --> total_loss
63+
total_loss --> gradients
64+
gradients --> check
65+
check -- not reached:<br> update --> train_vars
66+
check -- reached --> stop((("stop")))
67+
68+
classDef data shape: lean-r
69+
class prior_samples data
70+
```

docs/index.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
11
---8<--- "README.md:description"
2+
### Modular Capabilities of `elicito`
3+
Owing to its modular design, `elicito` accommodates key components across the entire elicitation workflow:
4+
5+
+ **Generative Models**: Support for a wide range of generative models (i.e., the statistical models describing the data-generating process).
6+
+ **Expert Knowledge**: Flexibility in defining different types of expert knowledge (i.e., the specific information elicited from the domain expert).
7+
+ **Elicitation Techniques**: Implementation of various types of elicitation techniques (e.g., quantile-based, histogram-based, or moment-based elicitation).
8+
+ **Loss Functions**: Integration of loss functions (i.e., the criterion used to quantify the discrepancy between the expert knowledge and the simulated model quantities).
9+
10+
### Computational Workflow
11+
The core logic of the expert prior elicitation method proposed in Bockting et al. (2024) can be summarized in a five-step workflow:
12+
13+
/// note | Core logic of method underlying elicito
14+
1. *Define the generative model*: Specify the generative model, including the functional form
15+
of the data distribution and the parametric family of prior distributions.
16+
2. *Define target quantities and elicitation techniques*: Select the set of target quantities
17+
and determine the elicitation techniques to query the expert (cf. elicited summaries).
18+
3. *Simulate elicited summaries*: Draw samples from the generative model and compute the
19+
corresponding set of simulated elicited summaries.
20+
4. *Evaluate discrepancy between simulated and expert-elicited summaries*: Assess the
21+
discrepancy between the simulated and expert-elicited summaries using a multi-objective loss
22+
function.
23+
5. *Adjust prior hyperparameters to minimize discrepancy*: Apply an optimization scheme to
24+
update the prior hyperparameters such that the loss function is minimized.
25+
///
26+
27+
![conceptual workflow](figures/conceptual-workflow.png)
28+
29+
## Getting started
30+
ToDo
31+
32+
### The `Elicit` class
33+
The primary user interface of **elicito** is the `Elicit` class, through which the user can specify the entire elicitation procedure. The arguments of the `Elicit` class are designed to capture all necessary information required to implement an elicitation method.
34+
A brief overview of these arguments is provided below:
35+
36+
+ `model`: Defines the generative model used in the elicitation procedure.
37+
+ `parameters`: Specifies assumptions regarding the prior distributions over model parameters,
38+
including (hyper)parameter constraints, dimensionality, and parametric form.
39+
+ `targets`: Defines the elicited statistics in terms of target quantities and corresponding
40+
elicitation techniques. Also specifies the discrepancy measure and weight used for the
41+
associated loss component.
42+
+ `expert`: Provides the expert information that serves as the basis for the learning criterion.
43+
+ `optimizer`: Specifies the optimization algorithm to be used, along with its
44+
hyperparameters (e.g., learning rate).
45+
+ `trainer`: Configures the overall training procedure, including settings such as the random
46+
seed, number of epochs, sample size, and batch size.
47+
+ `initializer`: Defines the initialization strategy for the hyperparameters used to
48+
instantiate the simulation-based optimization process.
49+
+ `networks`: Specifies the architecture of the deep generative model; required only when
50+
using non-parametric prior distributions.
51+
52+
By configuring these core components, **elicito** supports a wide range of elicitation methods, including both structural and predictive approaches, univariate and multivariate as well as parametric and nonparametric prior distributions.
53+
54+
## Main References
55+
56+
+ [Software Paper] Bockting F. & Bürkner PC (2025). elicito: A Python package for expert-prior elicitation. arXiv.
57+
[Preprint](https://arxiv.org/pdf/2506.16830)
58+
+ [Methods Paper] Bockting F., Radev ST, Bürkner PC (2024). Simulation-based prior knowledge elicitation
59+
for parametric Bayesian models. *Scientific Report, 14*(1), 17330. [PDF](https://www.nature.com/articles/s41598-024-68090-7)
60+
+ [Methods Paper] Bockting F., Radev ST, Bürkner PC (2025). Expert-elicitation method for non-parametric joint priors using
61+
normalizing flows. *Statistics and Computing*. [PDF](https://arxiv.org/abs/2411.15826)

mkdocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ theme:
2828
name: Switch to light mode
2929

3030
plugins:
31+
- mermaid2
3132
# https://mkdocstrings.github.io/autorefs/
3233
- autorefs
3334
# Required for auto-generating our documentation stubs
@@ -121,6 +122,11 @@ plugins:
121122
- section-index
122123

123124
markdown_extensions:
125+
- pymdownx.superfences:
126+
custom_fences:
127+
- name: mermaid
128+
class: mermaid
129+
format: !!python/name:mermaid2.fence_mermaid
124130
# https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/#attribute-lists
125131
- attr_list
126132
- footnotes

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ dev = [
9696
docs = [
9797
# Key dependencies
9898
# ----------------
99+
"mkdocs-mermaid2-plugin>=1.2.3",
99100
"attrs==25.3.0",
100101
"mkdocs-autorefs==1.4.2",
101102
"mkdocs-gen-files==0.5.0",

requirements-docs-locked.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ cycler==0.12.1
2525
debugpy==1.8.11
2626
decorator==5.1.1
2727
defusedxml==0.7.1
28+
editorconfig==0.17.1
2829
exceptiongroup==1.3.0 ; python_full_version < '3.11'
2930
executing==2.1.0
3031
fastjsonschema==2.21.1
@@ -46,6 +47,7 @@ ipython-pygments-lexers==1.1.1 ; python_full_version >= '3.11'
4647
isoduration==20.11.0
4748
jedi==0.19.2
4849
jinja2==3.1.5
50+
jsbeautifier==1.15.4
4951
json5==0.10.0
5052
jsonpointer==3.0.0
5153
jsonschema==4.23.0
@@ -80,6 +82,7 @@ mkdocs-jupyter==0.25.1
8082
mkdocs-literate-nav==0.6.2
8183
mkdocs-material==9.6.16
8284
mkdocs-material-extensions==1.3.1
85+
mkdocs-mermaid2-plugin==1.2.3
8386
mkdocs-section-index==0.3.10
8487
mkdocstrings==0.30.0
8588
mkdocstrings-python==1.16.12

0 commit comments

Comments
 (0)