causal-audit 0.3.2__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 (35) hide show
  1. causal_audit-0.3.2/PKG-INFO +215 -0
  2. causal_audit-0.3.2/README.md +162 -0
  3. causal_audit-0.3.2/causal_audit/__init__.py +26 -0
  4. causal_audit-0.3.2/causal_audit/a_auditor.py +1065 -0
  5. causal_audit-0.3.2/causal_audit/b_quantifier.py +606 -0
  6. causal_audit-0.3.2/causal_audit/c_recommender.py +928 -0
  7. causal_audit-0.3.2/causal_audit/config/calib_v1.yaml +93 -0
  8. causal_audit-0.3.2/causal_audit/config/calib_v2.yaml +440 -0
  9. causal_audit-0.3.2/causal_audit/config/method_catalog.yaml +135 -0
  10. causal_audit-0.3.2/causal_audit/config/priors_v1.yaml +66 -0
  11. causal_audit-0.3.2/causal_audit/gatekeeper.py +356 -0
  12. causal_audit-0.3.2/causal_audit/plotting/__init__.py +12 -0
  13. causal_audit-0.3.2/causal_audit/plotting/dataset_dashboards.py +396 -0
  14. causal_audit-0.3.2/causal_audit/plotting/dataset_dashboards_all_enhanced.py +418 -0
  15. causal_audit-0.3.2/causal_audit/plotting/dataset_dashboards_enhanced.py +146 -0
  16. causal_audit-0.3.2/causal_audit/plotting/dgp_atlas_detailed.py +321 -0
  17. causal_audit-0.3.2/causal_audit/plotting/diagnostic_dashboard.py +51 -0
  18. causal_audit-0.3.2/causal_audit/plotting/figures.py +1306 -0
  19. causal_audit-0.3.2/causal_audit/plotting/real_world_walkthroughs.py +524 -0
  20. causal_audit-0.3.2/causal_audit/plotting/scientific_plots.py +3145 -0
  21. causal_audit-0.3.2/causal_audit/utils/__init__.py +21 -0
  22. causal_audit-0.3.2/causal_audit/utils/io.py +175 -0
  23. causal_audit-0.3.2/causal_audit/utils/provenance.py +133 -0
  24. causal_audit-0.3.2/causal_audit/utils/schema_validation.py +188 -0
  25. causal_audit-0.3.2/causal_audit.egg-info/PKG-INFO +215 -0
  26. causal_audit-0.3.2/causal_audit.egg-info/SOURCES.txt +33 -0
  27. causal_audit-0.3.2/causal_audit.egg-info/dependency_links.txt +1 -0
  28. causal_audit-0.3.2/causal_audit.egg-info/requires.txt +35 -0
  29. causal_audit-0.3.2/causal_audit.egg-info/top_level.txt +1 -0
  30. causal_audit-0.3.2/pyproject.toml +109 -0
  31. causal_audit-0.3.2/setup.cfg +4 -0
  32. causal_audit-0.3.2/tests/test_integration.py +97 -0
  33. causal_audit-0.3.2/tests/test_nonlinearity_output.py +116 -0
  34. causal_audit-0.3.2/tests/test_schema_validation.py +77 -0
  35. causal_audit-0.3.2/tests/test_scientific_validation.py +449 -0
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: causal-audit
3
+ Version: 0.3.2
4
+ Summary: A framework for risk assessment of assumption violations in time-series causal discovery. Generates publication-quality pre-discovery figures (IEEE style) and method recommendations.
5
+ Author: Miguel Arana-Catania, David R. Ardila, Rodrigo Ventura
6
+ Author-email: Marco Ruiz <marco.rueda@tecnico.ulisboa.pt>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/marcoruizrueda/causal-audit
9
+ Project-URL: Documentation, https://github.com/marcoruizrueda/causal-audit/blob/main/README.md
10
+ Project-URL: Repository, https://github.com/marcoruizrueda/causal-audit
11
+ Project-URL: Issues, https://github.com/marcoruizrueda/causal-audit/issues
12
+ Keywords: causal-discovery,time-series,assumption-testing,bayesian,decision-support,risk-quantification,pre-discovery,pcmci,tigramite
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: <3.14,>=3.10
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: pandas>=1.3.0
24
+ Requires-Dist: numpy>=1.21.0
25
+ Requires-Dist: scipy>=1.7.0
26
+ Requires-Dist: statsmodels>=0.13.0
27
+ Requires-Dist: scikit-learn>=1.0.0
28
+ Requires-Dist: PyYAML>=6.0
29
+ Requires-Dist: matplotlib>=3.4.0
30
+ Requires-Dist: seaborn>=0.11.0
31
+ Provides-Extra: viz
32
+ Requires-Dist: matplotlib>=3.4.0; extra == "viz"
33
+ Requires-Dist: seaborn>=0.11.0; extra == "viz"
34
+ Requires-Dist: SciencePlots>=2.0.0; extra == "viz"
35
+ Provides-Extra: graphs
36
+ Requires-Dist: tigramite>=5.2.8; extra == "graphs"
37
+ Provides-Extra: eo
38
+ Requires-Dist: pyproj>=3.0.0; extra == "eo"
39
+ Requires-Dist: geopandas>=0.10.0; extra == "eo"
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
42
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
43
+ Requires-Dist: black>=22.0.0; extra == "dev"
44
+ Requires-Dist: flake8>=4.0.0; extra == "dev"
45
+ Requires-Dist: mypy>=0.950; extra == "dev"
46
+ Provides-Extra: all
47
+ Requires-Dist: matplotlib>=3.4.0; extra == "all"
48
+ Requires-Dist: seaborn>=0.11.0; extra == "all"
49
+ Requires-Dist: SciencePlots>=2.0.0; extra == "all"
50
+ Requires-Dist: tigramite>=5.2.8; extra == "all"
51
+ Requires-Dist: pyproj>=3.0.0; extra == "all"
52
+ Requires-Dist: geopandas>=0.10.0; extra == "all"
53
+
54
+ <div align="center">
55
+
56
+ # Causal-Audit
57
+
58
+ [![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)](https://www.python.org/downloads/)
59
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
60
+ [![Tests: 27/27](https://img.shields.io/badge/tests-27%2F27-brightgreen.svg)]()
61
+
62
+ <p align="center">
63
+ <a href="https://arxiv.org/abs/2604.02488"><b>📄 Paper (arXiv:2604.02488)</b></a>
64
+ </p>
65
+
66
+ <p align="center">
67
+ <img src="framework_overview.svg" width="95%" alt="Framework overview (Figure 1). Stage I computes diagnostics across five assumption families. Stages II–III add calibrated risk scores and an abstention-aware decision policy.">
68
+ </p>
69
+
70
+ A framework for risk assessment of assumption violations in time-series causal discovery.
71
+
72
+ </div>
73
+
74
+ > Ruiz, M.¹, Arana-Catania, M.², Ardila, D. R.³ & Ventura, R.¹ (2026).
75
+ > *Journal of Causal Inference.*
76
+ >
77
+ > ¹ ISR, Instituto Superior Técnico, Lisbon &nbsp;
78
+ > ² University of Oxford &nbsp;
79
+ > ³ Jet Propulsion Laboratory, Caltech
80
+
81
+ ## Contents
82
+
83
+ - [Install](#install)
84
+ - [Quickstart](#quickstart)
85
+ - [Usage](#usage)
86
+ - [Framework, figures & benchmarks](#framework-figures--benchmarks)
87
+ - [Reproducing paper experiments](#reproducing-paper-experiments)
88
+ - [Citation](#citation)
89
+ - [License](#license)
90
+
91
+ ## Install
92
+
93
+ ### Users
94
+
95
+ Install the released package with `uv` (recommended) or `pip`:
96
+
97
+ ```bash
98
+ uv pip install causal-audit
99
+ # or
100
+ pip install causal-audit
101
+ ```
102
+
103
+ Optional extras pull in the figure and graph dependencies:
104
+
105
+ ```bash
106
+ uv pip install "causal-audit[viz]" # IEEE-style figures (SciencePlots)
107
+ uv pip install "causal-audit[graphs]" # optional exploratory PCMCI+ graph via tigramite
108
+ uv pip install "causal-audit[all]" # viz + graphs + earth-observation helpers
109
+ ```
110
+
111
+ The package installs as `causal-audit` and imports as `causal_audit`.
112
+
113
+ ### Contributors
114
+
115
+ Clone the repository and install an editable copy into a fresh environment:
116
+
117
+ ```bash
118
+ git clone https://github.com/marcoruizrueda/causal-audit.git
119
+ cd causal-audit
120
+ uv venv .venv --python 3.13
121
+ source .venv/bin/activate
122
+ uv pip install -e .
123
+ ```
124
+
125
+ ## Quickstart
126
+
127
+ ```python
128
+ import pandas as pd
129
+ from causal_audit import RiskAwareGatekeeper
130
+
131
+ # DataFrame with a DatetimeIndex and one column per variable
132
+ df = pd.read_csv("data.csv", index_col=0, parse_dates=True)
133
+
134
+ gk = RiskAwareGatekeeper(random_seed=42)
135
+ result = gk.analyze(data=df, output_dir="results/")
136
+ print(result["policy"].decision) # "recommend" or "abstain"
137
+ print(result["policy"].recommended_method) # e.g. "PCMCI+" or "LPCMCI"
138
+ ```
139
+
140
+ Run the [quickstart notebook](examples/quickstart.ipynb) for a complete audit and its
141
+ summary figure. Use the independent [walkthrough](examples/walkthrough.ipynb) to
142
+ configure the audit, inspect diagnostics, and handle abstention. See [Usage](#usage)
143
+ for the per-stage API.
144
+
145
+ The default audit does not run causal discovery. The optional exploratory graph requires
146
+ `include_dependency_network=True` and Tigramite; it is skipped when the audit abstains.
147
+
148
+ ## Usage
149
+
150
+ Input: a `pandas.DataFrame` with a `DatetimeIndex`, one column per variable, `NaN` for missing values.
151
+
152
+ ```python
153
+ import pandas as pd
154
+ from causal_audit import AssumptionAuditor # Stage I
155
+ from causal_audit import RiskQuantifier # Stage II
156
+ from causal_audit import MethodRecommender # Stage III
157
+ from causal_audit import RiskAwareGatekeeper # Stages I → II → III
158
+
159
+ df = pd.read_csv("data.csv", index_col=0, parse_dates=True)
160
+
161
+ # Stage I — diagnostics (stationarity, irregularity, persistence, nonlinearity, confounding)
162
+ auditor = AssumptionAuditor(alpha=0.05)
163
+ evidence = auditor.audit(df) # → AuditEvidence with per-variable effect sizes
164
+
165
+ # Stage II — diagnostic-derived risk scores with approximate uncertainty bounds
166
+ quantifier = RiskQuantifier()
167
+ risk_profile = quantifier.quantify(evidence) # → RiskProfile (6 scores, bounds, ledger)
168
+
169
+ # Stage III — recommend a method or abstain
170
+ recommender = MethodRecommender()
171
+ policy, scorecard = recommender.recommend(risk_profile) # → Policy + Scorecard
172
+
173
+ # Or run all three stages at once:
174
+ gk = RiskAwareGatekeeper(random_seed=42)
175
+ result = gk.analyze(data=df, output_dir="results/")
176
+ print(result["policy"].decision) # "recommend" or "abstain"
177
+ print(result["policy"].recommended_method) # "PCMCI+" or "LPCMCI"
178
+ ```
179
+
180
+ Stage I can be used alone for structured assumption auditing in individual studies.
181
+ Use the gatekeeper for the complete configured pipeline: per-stage defaults do not
182
+ automatically load its calibration configuration or retain all downstream diagnostic inputs.
183
+
184
+ The paper evaluates four calibrated risk dimensions. The current implementation returns
185
+ six scores and includes heuristic fallbacks and overrides. Its uncertainty bounds and policy
186
+ confidence are not probabilities that a causal graph is correct; low confounding proxies
187
+ cannot establish causal sufficiency. Investigate severe nonstationarity and re-audit any
188
+ justified preprocessing before selecting a discovery method.
189
+
190
+ ## Framework, figures & benchmarks
191
+
192
+ The pipeline figure, the figure catalogue (six diagnostic figures plus an optional exploratory graph), the synthetic DGP atlas (F1–F10), the framework extension points, and the nonlinearity-diagnostic notes live in [FRAMEWORK.md](causal_audit/FRAMEWORK.md).
193
+
194
+ ## Reproducing paper experiments
195
+
196
+ See the step-by-step commands in [FRAMEWORK.md](causal_audit/FRAMEWORK.md#reproducing-paper-experiments).
197
+
198
+ ## Citation
199
+
200
+ ```bibtex
201
+ @misc{ruiz2026causalaudit,
202
+ title = {Causal-Audit: A Framework for Risk Assessment of Assumption
203
+ Violations in Time-Series Causal Discovery},
204
+ author = {Marco Ruiz and Miguel Arana-Catania and David R. Ardila
205
+ and Rodrigo Ventura},
206
+ year = {2026},
207
+ eprint = {2604.02488},
208
+ archivePrefix = {arXiv},
209
+ primaryClass = {cs.LG},
210
+ doi = {10.48550/arXiv.2604.02488},
211
+ url = {https://arxiv.org/abs/2604.02488},
212
+ }
213
+ ```
214
+
215
+ MIT License
@@ -0,0 +1,162 @@
1
+ <div align="center">
2
+
3
+ # Causal-Audit
4
+
5
+ [![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)](https://www.python.org/downloads/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Tests: 27/27](https://img.shields.io/badge/tests-27%2F27-brightgreen.svg)]()
8
+
9
+ <p align="center">
10
+ <a href="https://arxiv.org/abs/2604.02488"><b>📄 Paper (arXiv:2604.02488)</b></a>
11
+ </p>
12
+
13
+ <p align="center">
14
+ <img src="framework_overview.svg" width="95%" alt="Framework overview (Figure 1). Stage I computes diagnostics across five assumption families. Stages II–III add calibrated risk scores and an abstention-aware decision policy.">
15
+ </p>
16
+
17
+ A framework for risk assessment of assumption violations in time-series causal discovery.
18
+
19
+ </div>
20
+
21
+ > Ruiz, M.¹, Arana-Catania, M.², Ardila, D. R.³ & Ventura, R.¹ (2026).
22
+ > *Journal of Causal Inference.*
23
+ >
24
+ > ¹ ISR, Instituto Superior Técnico, Lisbon &nbsp;
25
+ > ² University of Oxford &nbsp;
26
+ > ³ Jet Propulsion Laboratory, Caltech
27
+
28
+ ## Contents
29
+
30
+ - [Install](#install)
31
+ - [Quickstart](#quickstart)
32
+ - [Usage](#usage)
33
+ - [Framework, figures & benchmarks](#framework-figures--benchmarks)
34
+ - [Reproducing paper experiments](#reproducing-paper-experiments)
35
+ - [Citation](#citation)
36
+ - [License](#license)
37
+
38
+ ## Install
39
+
40
+ ### Users
41
+
42
+ Install the released package with `uv` (recommended) or `pip`:
43
+
44
+ ```bash
45
+ uv pip install causal-audit
46
+ # or
47
+ pip install causal-audit
48
+ ```
49
+
50
+ Optional extras pull in the figure and graph dependencies:
51
+
52
+ ```bash
53
+ uv pip install "causal-audit[viz]" # IEEE-style figures (SciencePlots)
54
+ uv pip install "causal-audit[graphs]" # optional exploratory PCMCI+ graph via tigramite
55
+ uv pip install "causal-audit[all]" # viz + graphs + earth-observation helpers
56
+ ```
57
+
58
+ The package installs as `causal-audit` and imports as `causal_audit`.
59
+
60
+ ### Contributors
61
+
62
+ Clone the repository and install an editable copy into a fresh environment:
63
+
64
+ ```bash
65
+ git clone https://github.com/marcoruizrueda/causal-audit.git
66
+ cd causal-audit
67
+ uv venv .venv --python 3.13
68
+ source .venv/bin/activate
69
+ uv pip install -e .
70
+ ```
71
+
72
+ ## Quickstart
73
+
74
+ ```python
75
+ import pandas as pd
76
+ from causal_audit import RiskAwareGatekeeper
77
+
78
+ # DataFrame with a DatetimeIndex and one column per variable
79
+ df = pd.read_csv("data.csv", index_col=0, parse_dates=True)
80
+
81
+ gk = RiskAwareGatekeeper(random_seed=42)
82
+ result = gk.analyze(data=df, output_dir="results/")
83
+ print(result["policy"].decision) # "recommend" or "abstain"
84
+ print(result["policy"].recommended_method) # e.g. "PCMCI+" or "LPCMCI"
85
+ ```
86
+
87
+ Run the [quickstart notebook](examples/quickstart.ipynb) for a complete audit and its
88
+ summary figure. Use the independent [walkthrough](examples/walkthrough.ipynb) to
89
+ configure the audit, inspect diagnostics, and handle abstention. See [Usage](#usage)
90
+ for the per-stage API.
91
+
92
+ The default audit does not run causal discovery. The optional exploratory graph requires
93
+ `include_dependency_network=True` and Tigramite; it is skipped when the audit abstains.
94
+
95
+ ## Usage
96
+
97
+ Input: a `pandas.DataFrame` with a `DatetimeIndex`, one column per variable, `NaN` for missing values.
98
+
99
+ ```python
100
+ import pandas as pd
101
+ from causal_audit import AssumptionAuditor # Stage I
102
+ from causal_audit import RiskQuantifier # Stage II
103
+ from causal_audit import MethodRecommender # Stage III
104
+ from causal_audit import RiskAwareGatekeeper # Stages I → II → III
105
+
106
+ df = pd.read_csv("data.csv", index_col=0, parse_dates=True)
107
+
108
+ # Stage I — diagnostics (stationarity, irregularity, persistence, nonlinearity, confounding)
109
+ auditor = AssumptionAuditor(alpha=0.05)
110
+ evidence = auditor.audit(df) # → AuditEvidence with per-variable effect sizes
111
+
112
+ # Stage II — diagnostic-derived risk scores with approximate uncertainty bounds
113
+ quantifier = RiskQuantifier()
114
+ risk_profile = quantifier.quantify(evidence) # → RiskProfile (6 scores, bounds, ledger)
115
+
116
+ # Stage III — recommend a method or abstain
117
+ recommender = MethodRecommender()
118
+ policy, scorecard = recommender.recommend(risk_profile) # → Policy + Scorecard
119
+
120
+ # Or run all three stages at once:
121
+ gk = RiskAwareGatekeeper(random_seed=42)
122
+ result = gk.analyze(data=df, output_dir="results/")
123
+ print(result["policy"].decision) # "recommend" or "abstain"
124
+ print(result["policy"].recommended_method) # "PCMCI+" or "LPCMCI"
125
+ ```
126
+
127
+ Stage I can be used alone for structured assumption auditing in individual studies.
128
+ Use the gatekeeper for the complete configured pipeline: per-stage defaults do not
129
+ automatically load its calibration configuration or retain all downstream diagnostic inputs.
130
+
131
+ The paper evaluates four calibrated risk dimensions. The current implementation returns
132
+ six scores and includes heuristic fallbacks and overrides. Its uncertainty bounds and policy
133
+ confidence are not probabilities that a causal graph is correct; low confounding proxies
134
+ cannot establish causal sufficiency. Investigate severe nonstationarity and re-audit any
135
+ justified preprocessing before selecting a discovery method.
136
+
137
+ ## Framework, figures & benchmarks
138
+
139
+ The pipeline figure, the figure catalogue (six diagnostic figures plus an optional exploratory graph), the synthetic DGP atlas (F1–F10), the framework extension points, and the nonlinearity-diagnostic notes live in [FRAMEWORK.md](causal_audit/FRAMEWORK.md).
140
+
141
+ ## Reproducing paper experiments
142
+
143
+ See the step-by-step commands in [FRAMEWORK.md](causal_audit/FRAMEWORK.md#reproducing-paper-experiments).
144
+
145
+ ## Citation
146
+
147
+ ```bibtex
148
+ @misc{ruiz2026causalaudit,
149
+ title = {Causal-Audit: A Framework for Risk Assessment of Assumption
150
+ Violations in Time-Series Causal Discovery},
151
+ author = {Marco Ruiz and Miguel Arana-Catania and David R. Ardila
152
+ and Rodrigo Ventura},
153
+ year = {2026},
154
+ eprint = {2604.02488},
155
+ archivePrefix = {arXiv},
156
+ primaryClass = {cs.LG},
157
+ doi = {10.48550/arXiv.2604.02488},
158
+ url = {https://arxiv.org/abs/2604.02488},
159
+ }
160
+ ```
161
+
162
+ MIT License
@@ -0,0 +1,26 @@
1
+ """
2
+ causal-audit: A Framework for Risk Assessment of Assumption Violations
3
+ in Time-Series Causal Discovery.
4
+
5
+ Ruiz et al. (2026). Journal of Causal Inference.
6
+ https://github.com/marcoruizrueda/causal-audit
7
+ """
8
+
9
+ __version__ = "0.3.2"
10
+ __author__ = "Marco Ruiz, Miguel Arana-Catania, David R. Ardila, Rodrigo Ventura"
11
+ __license__ = "MIT"
12
+
13
+ # Main public API
14
+ from .gatekeeper import RiskAwareGatekeeper
15
+
16
+ # Core modules (can be used independently)
17
+ from .a_auditor import AssumptionAuditor
18
+ from .b_quantifier import RiskQuantifier
19
+ from .c_recommender import MethodRecommender
20
+
21
+ __all__ = [
22
+ "RiskAwareGatekeeper",
23
+ "AssumptionAuditor",
24
+ "RiskQuantifier",
25
+ "MethodRecommender",
26
+ ]