Skip to content

Commit 6071bd3

Browse files
committed
Reworked examples
1 parent 78d1c3d commit 6071bd3

File tree

14 files changed

+229
-1529
lines changed

14 files changed

+229
-1529
lines changed

causal_testing/testing/causal_test_case.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def __init__(
3939
:param expected_causal_effect: The expected causal effect (Positive, Negative, No Effect).
4040
:param control_value: The control value for the treatment variable (before intervention).
4141
:param treatment_value: The treatment value for the treatment variable (after intervention).
42-
:param estimate_type: A string which denotes the type of estimate to return
43-
:param effect_modifier_configuration:
44-
:param estimator: An Estimator class instance
42+
:param estimate_type: A string which denotes the type of estimate to return.
43+
:param effect_modifier_configuration: The assignment of the effect modifiers to use for estimates.
44+
:param estimator: An Estimator class object
4545
"""
4646
self.base_test_case = base_test_case
4747
self.control_value = control_value

causal_testing/testing/causal_test_suite.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ def add_test_object(
3131
self,
3232
base_test_case: BaseTestCase,
3333
causal_test_case_list: Iterable[CausalTestCase],
34-
estimators_classes: Iterable[Type[Estimator]],
34+
estimators: Iterable[Type[Estimator]],
3535
estimate_type: str = "ate",
3636
):
3737
"""
3838
A setter object to allow for the easy construction of the dictionary test suite structure
3939
4040
:param base_test_case: A BaseTestCase object consisting of a treatment variable, outcome variable and effect
4141
:param causal_test_case_list: A list of causal test cases to be executed
42-
:param estimators_classes: A list of estimators, one for each causal test case
42+
:param estimators: A list of estimator classes (NOT instances) to be used to execute each of the test cases.
43+
Each estimator will be applied to each test case, so this will typically just be a single element list.
44+
However, if you want to compare the outputs of different estimators, you may include more than one class here.
4345
:param estimate_type: A string which denotes the type of estimate to return
4446
"""
45-
test_object = {"tests": causal_test_case_list, "estimators": estimators_classes, "estimate_type": estimate_type}
47+
test_object = {"tests": causal_test_case_list, "estimators": estimators, "estimate_type": estimate_type}
4648
self.data[base_test_case] = test_object
4749

4850
def execute_test_suite(

examples/covasim_/vaccinating_elderly/example_vaccine.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def setup_test_case(verbose: bool = False):
5050
cum_vaccinations,
5151
max_doses,
5252
},
53-
constraints={pop_size.z3 == 50000, pop_infected.z3 == 1000, n_days.z3 == 50},
5453
)
5554

5655
# 4. Construct a causal specification from the scenario and causal DAG

examples/poisson-line-process/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ To run this case study:
66
1. Ensure all project dependencies are installed by running `pip install .` in the top level directory
77
(instructions are provided in the project README).
88
2. Change directory to `causal_testing/examples/poisson-line-process`.
9-
3. Run the command `python example_poisson_process.py`
9+
3. Run the command `python example_pure_python.py` to demonstrate causal testing using pure python.
10+
3. Run the command `python example_json_frontend.py` to demonstrate the same causal tests using JSON.
1011

1112
This should print a series of causal test results and produce two CSV files. `intensity_num_shapes_results_random_1000.csv` corresponds to table 1, and `width_num_shapes_results_random_1000.csv` relates to our findings regarding the relationship of width and `P_u`.

examples/poisson/causal_tests.json renamed to examples/poisson-line-process/causal_tests.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
{
44
"name": "width__num_lines_abs",
55
"mutations": {"width": "Increase"},
6-
"estimator": "WidthHeightEstimator",
6+
"estimator": "LinearRegressionEstimator",
7+
"formula": "num_lines_abs ~ I(intensity * (width + height))",
78
"estimate_type": "ate",
89
"effect_modifiers": ["intensity", "height"],
910
"expected_effect": {"num_lines_abs": "PoissonWidthHeight"},
@@ -138,7 +139,8 @@
138139
{
139140
"name": "height__num_lines_abs",
140141
"mutations": {"height": "Increase"},
141-
"estimator": "WidthHeightEstimator",
142+
"estimator": "LinearRegressionEstimator",
143+
"formula": "num_lines_abs ~ I(intensity * (width + height))",
142144
"estimate_type": "ate",
143145
"effect_modifiers": ["intensity", "width"],
144146
"expected_effect": {"num_lines_abs": "PoissonWidthHeight"},
@@ -192,7 +194,8 @@
192194
{
193195
"name": "intensity__num_lines_abs",
194196
"mutations": {"intensity": "Increase"},
195-
"estimator": "WidthHeightEstimator",
197+
"estimator": "LinearRegressionEstimator",
198+
"formula": "num_lines_abs ~ I(intensity * (width + height))",
196199
"effect_modifiers": ["height", "width"],
197200
"estimate_type": "ate",
198201
"expected_effect": {"num_lines_abs": "PoissonIntensity"},

examples/poisson-line-process/dag.dot

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
digraph poisson_line_process {
2-
rankdir=LR;
32
width -> num_lines_abs;
43
width -> num_shapes_abs;
54
width -> num_lines_unit;

examples/poisson-line-process/example_poisson_process.py

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)