metadentify 0.1.0a0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. metadentify-0.1.0a0/.github/workflows/ci.yml +63 -0
  2. metadentify-0.1.0a0/.github/workflows/publish.yml +44 -0
  3. metadentify-0.1.0a0/LICENSE +201 -0
  4. metadentify-0.1.0a0/Makefile +32 -0
  5. metadentify-0.1.0a0/PKG-INFO +220 -0
  6. metadentify-0.1.0a0/README.md +179 -0
  7. metadentify-0.1.0a0/devtools/lint.py +53 -0
  8. metadentify-0.1.0a0/docs/development.md +94 -0
  9. metadentify-0.1.0a0/docs/images/cnp_diagram.png +0 -0
  10. metadentify-0.1.0a0/docs/images/dags_and_curve.png +0 -0
  11. metadentify-0.1.0a0/docs/images/example_curves_1.png +0 -0
  12. metadentify-0.1.0a0/docs/images/example_curves_2.png +0 -0
  13. metadentify-0.1.0a0/docs/images/id_diagram.svg +621 -0
  14. metadentify-0.1.0a0/docs/images/p_identifiability.png +0 -0
  15. metadentify-0.1.0a0/docs/installation.md +27 -0
  16. metadentify-0.1.0a0/docs/publishing.md +213 -0
  17. metadentify-0.1.0a0/experiments/example_experiment.py +324 -0
  18. metadentify-0.1.0a0/experiments/example_sweep.yaml +67 -0
  19. metadentify-0.1.0a0/pyproject.toml +198 -0
  20. metadentify-0.1.0a0/src/metadentify/__init__.py +0 -0
  21. metadentify-0.1.0a0/src/metadentify/args.py +59 -0
  22. metadentify-0.1.0a0/src/metadentify/baselines.py +460 -0
  23. metadentify-0.1.0a0/src/metadentify/launch_sweep.py +153 -0
  24. metadentify-0.1.0a0/src/metadentify/mechanisms.py +167 -0
  25. metadentify-0.1.0a0/src/metadentify/mixture.py +778 -0
  26. metadentify-0.1.0a0/src/metadentify/modules.py +926 -0
  27. metadentify-0.1.0a0/src/metadentify/py.typed +0 -0
  28. metadentify-0.1.0a0/src/metadentify/queries.py +147 -0
  29. metadentify-0.1.0a0/src/metadentify/run_experiment.py +94 -0
  30. metadentify-0.1.0a0/src/metadentify/sbatch.py +52 -0
  31. metadentify-0.1.0a0/src/metadentify/train.py +276 -0
  32. metadentify-0.1.0a0/src/metadentify/utils.py +49 -0
  33. metadentify-0.1.0a0/tests/test_placeholder.py +3 -0
  34. metadentify-0.1.0a0/uv.lock +3909 -0
@@ -0,0 +1,63 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: CI
5
+
6
+ on:
7
+ push:
8
+ # Use ["main", "master"] for CI only on the default branch.
9
+ # Use ["**"] for CI on all branches.
10
+ branches: ["main", "master"]
11
+ pull_request:
12
+ branches: ["main", "master"]
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ build:
19
+ strategy:
20
+ matrix:
21
+ # Update this as needed:
22
+ # Common platforms: ["ubuntu-latest", "macos-latest", "windows-latest"]
23
+ os: ["ubuntu-latest"]
24
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
25
+
26
+ # Linux only by default. Use ${{ matrix.os }} for other OSes.
27
+ runs-on: ${{ matrix.os }}
28
+
29
+ steps:
30
+ # Generally following uv docs:
31
+ # https://docs.astral.sh/uv/guides/integration/github/
32
+
33
+ - name: Checkout (official GitHub action)
34
+ uses: actions/checkout@v6
35
+ with:
36
+ # Important for versioning plugins:
37
+ fetch-depth: 0
38
+
39
+ - name: Install uv (official Astral action)
40
+ uses: astral-sh/setup-uv@v7
41
+ with:
42
+ # Update this as needed:
43
+ version: "0.10.2"
44
+ enable-cache: true
45
+ python-version: ${{ matrix.python-version }}
46
+
47
+ - name: Set up Python (using uv)
48
+ run: uv python install
49
+
50
+ # Alternately can use the official Python action:
51
+ # - name: Set up Python (using actions/setup-python)
52
+ # uses: actions/setup-python@v5
53
+ # with:
54
+ # python-version: ${{ matrix.python-version }}
55
+
56
+ - name: Install all dependencies
57
+ run: uv sync --all-extras
58
+
59
+ - name: Run linting
60
+ run: uv run python devtools/lint.py
61
+
62
+ - name: Run tests
63
+ run: uv run pytest
@@ -0,0 +1,44 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch: # Enable manual trigger.
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # Mandatory for OIDC.
13
+ contents: read
14
+ steps:
15
+ - name: Checkout (official GitHub action)
16
+ uses: actions/checkout@v6
17
+ with:
18
+ # Important for versioning plugins:
19
+ fetch-depth: 0
20
+
21
+ - name: Install uv (official Astral action)
22
+ uses: astral-sh/setup-uv@v7
23
+ with:
24
+ version: "0.10.2"
25
+ enable-cache: true
26
+ python-version: "3.12"
27
+
28
+ - name: Set up Python (using uv)
29
+ run: uv python install
30
+
31
+ - name: Install all dependencies
32
+ run: uv sync --all-extras
33
+
34
+ - name: Run tests
35
+ run: uv run pytest
36
+
37
+ - name: Build package
38
+ run: uv build
39
+
40
+ - name: Publish to PyPI
41
+ run: uv publish --trusted-publishing always
42
+ # Although uv is newer and faster, the "official" publishing option is the one from PyPA,
43
+ # which uses twine. If desired, replace `uv publish` with:
44
+ # uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,32 @@
1
+ # Makefile for easy development workflows.
2
+ # See docs/development.md for docs.
3
+ # Note GitHub Actions call uv directly, not this Makefile.
4
+
5
+ .DEFAULT_GOAL := default
6
+
7
+ .PHONY: default install lint test upgrade build clean
8
+
9
+ default: install lint test
10
+
11
+ install:
12
+ uv sync --all-extras
13
+
14
+ lint:
15
+ uv run python devtools/lint.py
16
+
17
+ test:
18
+ uv run pytest
19
+
20
+ upgrade:
21
+ uv sync --upgrade --all-extras --dev
22
+
23
+ build:
24
+ uv build
25
+
26
+ clean:
27
+ -rm -rf dist/
28
+ -rm -rf *.egg-info/
29
+ -rm -rf .pytest_cache/
30
+ -rm -rf .mypy_cache/
31
+ -rm -rf .venv/
32
+ -find . -type d -name "__pycache__" -exec rm -rf {} +
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.4
2
+ Name: metadentify
3
+ Version: 0.1.0a0
4
+ Summary: Meta/in-context/amortized causal inference for computational identifiability
5
+ Project-URL: Repository, https://github.com/lbynum/metadentify
6
+ Author-email: "Lucius E.J. Bynum" <lucius@nyu.edu>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: <4.0,>=3.10
21
+ Requires-Dist: cloudpickle>=3.1.2
22
+ Requires-Dist: dowhy>=0.14.0
23
+ Requires-Dist: econml>=0.16.0
24
+ Requires-Dist: filelock>=3.0.0
25
+ Requires-Dist: graphviz>=0.20.0
26
+ Requires-Dist: joblib>=1.2.0
27
+ Requires-Dist: matplotlib>=3.7.1
28
+ Requires-Dist: networkx>=3.0
29
+ Requires-Dist: numpy>=1.24.0
30
+ Requires-Dist: pandas>=2.0.0
31
+ Requires-Dist: pillow>=9.0.0
32
+ Requires-Dist: python-dotenv>=1.2.2
33
+ Requires-Dist: pytorch-lightning>=2.0.0
34
+ Requires-Dist: scikit-learn>=1.2.0
35
+ Requires-Dist: scipy>=1.10.1
36
+ Requires-Dist: seaborn>=0.12.2
37
+ Requires-Dist: torch>=2.0.0
38
+ Requires-Dist: tqdm>=4.65.0
39
+ Requires-Dist: wandb>=0.25.1
40
+ Description-Content-Type: text/markdown
41
+
42
+ # `metadentify`: Meta/in-context/amortized causal inference for computational identifiability
43
+
44
+ [![PyPI version](https://badge.fury.io/py/metadentify.svg)](https://badge.fury.io/py/metadentify)
45
+ [![arXiv](https://img.shields.io/badge/arXiv-ARXIV.ID-b31b1b.svg)](https://arxiv.org/abs/ARXIV.ID)
46
+ ![PyTorch Lightning](https://img.shields.io/badge/pytorch-lightning-blue.svg?logo=PyTorch%20Lightning)
47
+ [![CI](https://github.com/lbynum/metadentify/actions/workflows/ci.yml/badge.svg)](https://github.com/lbynum/metadentify/actions)
48
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
49
+ [![Code style: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
50
+ [![License](https://img.shields.io/badge/License-Apache_2.0-green)](LICENSE)
51
+
52
+ <figure align="center">
53
+ <img align="center" src="docs/images/id_diagram.svg">
54
+ </figure>
55
+
56
+ > Two approaches to identifiability. Mathematical derivation (top) seeks to prove the existence of a unique parameter, analytically in expectation. Computational search (bottom, implemented in this repository) instead defines an empirical search procedure for an estimator and defines 'computational identifiability' as the successful discovery of an estimator, conditional on a prior over parameters, a hypothesis space over estimators, finite samples, and a desired error tolerance.
57
+
58
+ </br>
59
+
60
+ This repository contains the official code and resources for the paper [**Computational Identifiability**](https://arxiv.org/abs/ARXIV.ID) (https://arxiv.org/abs/ARXIV.ID).
61
+
62
+ ## Overview
63
+
64
+ A critical step in answering a causal or statistical query from data is determining if there is sufficient information to compute a unique answer. Traditionally, **theoretical identifiability** achieves this mathematically in expectation, often relying on mathematically idealized conditions like asymptotic properties or infinite data.
65
+
66
+ However, in many practical scenarios—such as those with finite sample sizes, ambiguous graphical criteria, or complex combinations of observational and experimental data—theoretical guarantees may offer little guidance on whether a target parameter can actually be estimated.
67
+
68
+ This motivates **computational identifiability**, a complemetary notion of identifiability that is computation-bound. Instead of analytical mathematical derivation, it frames identifiability as a finite computational search procedure for an empirical estimator.
69
+
70
+ ## What is Computational Identifiability?
71
+
72
+ Computational identifiability starts with:
73
+ 1. A meta-prior over the parameters in question (e.g., a distribution over structural causal models, or SCMs).
74
+ 2. A hypothesis space of possible estimators (e.g., an instantiated Conditional Neural Process, a pre-trained tabular foundation model, etc.).
75
+
76
+ For a given finite sample size, error tolerance, and confidence bound, computational identifiability is satisfied if an empirical estimator exists within the hypothesis space that can successfully estimate the query within the desired error margin.
77
+
78
+ ## Framework & methodology
79
+
80
+ To operationalize this search, we generalize the connection between causal effect estimation and meta-learning.
81
+
82
+ <figure align="center">
83
+ <img align="center" src="docs/images/cnp_diagram.png">
84
+ </figure>
85
+
86
+ To meta-learn causal estimators, we define context set $D_c$ of $n$ observations $O=o$ and source labels $S=s$. Source labels can be, e.g., indicators for 'observational,' 'interventional,' 'counterfactual,' etc., corresponding to each type of data available for meta-training. We then define the target set $D_t$ consisting of $m$ query points $X_t=x_t$ and corresponding realized causal query values $\Theta_t = \theta_t$. The meta-model processes these inputs in the style of a conditional neural process (CNP) as pictured in the diagram above (see Section 3.1.1 in the paper for full architecture descriptions).
87
+
88
+
89
+ <figure align="center">
90
+ <img align="center" src="docs/images/dags_and_curve.png">
91
+ </figure>
92
+
93
+ > **(a)-(f)** A few example DAGs we consider in the paper. **(Right)** Diagram showing *computational identifiability curves*, visualizing computational identifiability across a range of possible $\epsilon$ values. The empirical (or posterior) probability of identifiability can be read at a given desired error tolerance (see Section 3.2 in the paper for the corresponding algorithm).
94
+
95
+
96
+ * **Meta-learning causal effect estimators:** We learn mappings from observations and query points to causal query values by training on joint distributions over SCMs, observations, and query values. The `experiments/` folder demonstrates applying this same meta-learning process to several settings.
97
+
98
+
99
+ * **Architectures:** This repository implements two Conditional Neural Process (CNP) style architectures with conformalized quantile regression to use out-of-the-box (see `modules.py`). The Q-CNP uses mean-pooling and Q-TNP uses attention-based processing.
100
+
101
+ * **Posterior estimates:** By using models that support posterior uncertainty, we can directly estimate the **probability of identifiability** for any new data at test-time.
102
+
103
+
104
+ ## Codebase & features
105
+
106
+ This package is designed for modularity, scalable training, and easy experimentation.
107
+
108
+ ### Causal mixtures & `dowhy` integration
109
+ * **`mixture.py`**: This module directly implements the joint-causal-query-mixture distribution used to generate meta-training data (see Definitions 1-6 in the paper for details).
110
+ * **`dowhy` backend**: The codebase natively supports the `dowhy` package (specifically `dowhy.gcm`) as its language for specifying structural causal models. This provides an intuitive and standardized way to experiment with new causal graphs and mechanisms. This allows easy experimentation with **observational, interventional, and counterfactual** data and estimands.
111
+
112
+ ### Infrastructure & scaling
113
+ The repository is optimized to easily scale up meta-learning experiments with distributed computing environments:
114
+ * **Weights & Biases (W&B):** Fully integrated for experiment tracking and metric logging built into the meta-model (`modules.py`).
115
+ * **SLURM cluster support:** Built-in utilities (`sbatch.py`) to easily format and launch parallel SLURM jobs for distributed training or sweeping.
116
+ * **Singularity environments:** Natively supports encapsulating and running your training scripts and sweeps inside Singularity containers for reproducible and isolated execution (`launch_sweep.py`).
117
+
118
+ > [!NOTE]
119
+ > Additional features under development. Stay tuned :)
120
+
121
+ * * *
122
+
123
+ ## Usage examples
124
+
125
+ Below are usage examples for computational identifiability experiments. The same `run-experiment` function can be called and routed to different experiment files (e.g., `experiments/example_experiment.py`). The `--log_identifiability` flag can be added to any experiment to log the identifiability curve to W&B for normalized epsilon from 0-2.5. In addition, many other arguments are possible (see `args.py` for a full list of arguments). All runs and sweeps will automatically log to Weights&Biases unless `--disable_wandb` is passed.
126
+
127
+ <figure align="center">
128
+ <img align="center" src="docs/images/example_curves_1.png">
129
+ </figure>
130
+
131
+ > Identifiability curves from meta-models (the Q-CNP backbone in modules.py) trained on each of the cases in example_experiment.py, as a function of varying dataset size $N$.
132
+
133
+ </br>
134
+
135
+ <figure align="center">
136
+ <img align="center" src="docs/images/example_curves_2.png">
137
+ </figure>
138
+
139
+ > Identifiability curves from per-dataset estimation methods (implemented in baselines.py) instead of meta-trained models, for each of the cases in example_experiment.py.
140
+
141
+
142
+ The above figures plot P(identifiability) values from the W&B sweep defined in `example_sweep.yaml`, which automates running `example_experiment.py` across a range of parameters (see below for W&B setup instructions).
143
+
144
+ ### Local runs
145
+
146
+ ```bash
147
+ # run a single experiment locally with W&B logging
148
+ uv run run-experiment --experiment_setup_path experiments/example_experiment.py --experiment_name proxy --num_train_tasks 1000 --num_val_tasks 100 --num_test_tasks 100 --max_epochs 100
149
+ ```
150
+
151
+
152
+ ### Running with SLURM + Singularity + Weights&Biases Sweeps
153
+
154
+ Create a `.env` file with the following variables for wandb, slurm, and singularity environment settings.
155
+ ```
156
+ WANDB_API_KEY=your_api_key
157
+ WANDB_ENTITY=org_name
158
+ WANDB_PROJECT=project_name
159
+
160
+ SLURM_USER_EMAIL=email@email.com
161
+ SLURM_ACCOUNT_NAME=slurm_account_name
162
+
163
+ SINGULARITY_ENV_PATH=/singularity/path
164
+ SINGULARITY_CONTAINER_PATH=singularity/container/path
165
+ ```
166
+
167
+ #### Local W&B sweeps
168
+
169
+ In this example, we run a W&B sweep locally, with parameters defined in `experiments/example_sweep.yaml`.
170
+
171
+ ```bash
172
+ # create sweep using config yaml
173
+ uv run wandb sweep experiments/example_sweep.yaml
174
+ > wandb: Creating sweep from: experiments/example_sweep.yaml
175
+ > wandb: Creating sweep with ID: abcd1234
176
+ > wandb: View sweep at: https://wandb.ai/wandb-entity/wandb-project/sweeps/abcd1234
177
+ > wandb: Run sweep agent with: wandb agent wandb-entity/metadentify/abcd1234
178
+ # start corresponding sweep agent
179
+ uv run wandb agent wandb-entity/metadentify/abcd1234
180
+ ```
181
+
182
+ #### Distributed W&B sweeps on SLURM inside a Singularity container
183
+
184
+ In this example, we launch a 12-node distributed sweep experiment on SLURM inside a Singularity environment with W&B logging (using the same `experiments/example_sweep.yaml` config):
185
+
186
+ ```bash
187
+ # first, create small virtual env for python-dotenv
188
+ python3 -m venv .venv-launcher
189
+ source .venv-launcher/bin/activate
190
+ pip install python-dotenv
191
+
192
+ # now launch the distributed sweep inside Singularity
193
+ python src/metadentify/launch_sweep.py --config experiments/example_sweep.yaml --num_jobs 12
194
+ ```
195
+
196
+ ## Citation
197
+
198
+ If you find this code or concept useful in your research, please cite the corresponding papers:
199
+
200
+ ```
201
+ @article{bynum2026computational,
202
+ title={Computational Identifiability},
203
+ author={Bynum, Lucius EJ and Ranganath, Rajesh and Cho, Kyunghyun},
204
+ journal={arXiv preprint arXiv:ARXIV.ID},
205
+ year={2026}
206
+ }
207
+
208
+ @article{bynum2025black,
209
+ title={Black Box Causal Inference: Effect Estimation via Meta Prediction},
210
+ author={Bynum, Lucius EJ and Puli, Aahlad Manas and Herrero-Quevedo, Diego and Nguyen, Nhi and Fernandez-Granda, Carlos and Cho, Kyunghyun and Ranganath, Rajesh},
211
+ journal={arXiv preprint arXiv:2503.05985},
212
+ year={2025}
213
+ }
214
+ ```
215
+
216
+ * * *
217
+
218
+ <p align="center">
219
+ Package made with <a href="https://github.com/jlevy/simple-modern-uv" target="_blank"> simple-modern-uv </a>
220
+ </p>