Skip to content

Commit 5d57aee

Browse files
committed
Pylint
1 parent 93343f2 commit 5d57aee

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

causal_testing/estimation/abstract_regression_estimator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ def __init__(
5656
[base_test_case.treatment_variable.name] + sorted(list(adjustment_set)) + sorted(list(effect_modifiers))
5757
)
5858
self.formula = f"{base_test_case.outcome_variable.name} ~ {'+'.join(terms)}"
59-
self.setup_formula()
59+
self.setup_covariates()
6060

61-
def setup_formula(self):
61+
def setup_covariates(self):
62+
"""
63+
Parse the formula and set up the covariates from the design matrix so we can use them in the statsmodels array
64+
API. This allows us to only parse the formula once, rather than using the formula API, which parses it every
65+
time the regression model is fit, which can be a lot if using causal test adequacy.
66+
"""
6267
if self.df is not None:
6368
_, covariate_data = dmatrices(self.formula, self.df, return_type="dataframe")
6469
self.covariates = covariate_data.columns

causal_testing/estimation/linear_regression_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def gp_formula(
9292
formula = gp.run_gp(ngen=ngen, pop_size=pop_size, num_offspring=num_offspring, seeds=seeds)
9393
formula = gp.simplify(formula)
9494
self.formula = f"{self.base_test_case.outcome_variable.name} ~ I({formula}) - 1"
95-
self.setup_formula()
95+
self.setup_covariates()
9696

9797
def estimate_coefficient(self) -> EffectEstimate:
9898
"""Estimate the unit average treatment effect of the treatment on the outcome. That is, the change in outcome

causal_testing/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ def save_results(self, results: List[CausalTestResult], output_path: str = None)
442442
result_index = 0
443443

444444
for test_config in test_configs["tests"]:
445-
446445
# Create a base output first of common entries
447446
base_output = {
448447
"name": test_config["name"],

docs/source/tutorials/vaccinating_elderly/causal_test_results.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"expected_effect": {
88
"cum_vaccinations": "NoEffect"
99
},
10-
"formula": "cum_vaccinations ~ max_doses",
1110
"alpha": 0.05,
11+
"formula": "cum_vaccinations ~ max_doses",
1212
"skip": false,
1313
"passed": false,
1414
"result": {
@@ -35,8 +35,8 @@
3535
"expected_effect": {
3636
"cum_vaccinated": "NoEffect"
3737
},
38-
"formula": "cum_vaccinated ~ max_doses",
3938
"alpha": 0.05,
39+
"formula": "cum_vaccinated ~ max_doses",
4040
"skip": false,
4141
"passed": false,
4242
"result": {
@@ -63,8 +63,8 @@
6363
"expected_effect": {
6464
"cum_infections": "NoEffect"
6565
},
66-
"formula": "cum_infections ~ max_doses",
6766
"alpha": 0.05,
67+
"formula": "cum_infections ~ max_doses",
6868
"skip": false,
6969
"passed": false,
7070
"result": {
@@ -91,8 +91,8 @@
9191
"expected_effect": {
9292
"cum_vaccinations": "SomeEffect"
9393
},
94-
"formula": "cum_vaccinations ~ vaccine",
9594
"alpha": 0.05,
95+
"formula": "cum_vaccinations ~ vaccine",
9696
"skip": false,
9797
"passed": true,
9898
"result": {
@@ -119,8 +119,8 @@
119119
"expected_effect": {
120120
"cum_vaccinated": "SomeEffect"
121121
},
122-
"formula": "cum_vaccinated ~ vaccine",
123122
"alpha": 0.05,
123+
"formula": "cum_vaccinated ~ vaccine",
124124
"skip": false,
125125
"passed": true,
126126
"result": {
@@ -147,8 +147,8 @@
147147
"expected_effect": {
148148
"cum_infections": "SomeEffect"
149149
},
150-
"formula": "cum_infections ~ vaccine",
151150
"alpha": 0.05,
151+
"formula": "cum_infections ~ vaccine",
152152
"skip": false,
153153
"passed": true,
154154
"result": {
@@ -175,8 +175,8 @@
175175
"expected_effect": {
176176
"cum_vaccinated": "NoEffect"
177177
},
178-
"formula": "cum_vaccinated ~ cum_vaccinations + vaccine",
179178
"alpha": 0.05,
179+
"formula": "cum_vaccinated ~ cum_vaccinations + vaccine",
180180
"skip": false,
181181
"passed": false,
182182
"result": {
@@ -205,8 +205,8 @@
205205
"expected_effect": {
206206
"cum_infections": "NoEffect"
207207
},
208-
"formula": "cum_infections ~ cum_vaccinations + vaccine",
209208
"alpha": 0.05,
209+
"formula": "cum_infections ~ cum_vaccinations + vaccine",
210210
"skip": false,
211211
"passed": true,
212212
"result": {
@@ -235,8 +235,8 @@
235235
"expected_effect": {
236236
"cum_infections": "NoEffect"
237237
},
238-
"formula": "cum_infections ~ cum_vaccinated + vaccine",
239238
"alpha": 0.05,
239+
"formula": "cum_infections ~ cum_vaccinated + vaccine",
240240
"skip": false,
241241
"passed": true,
242242
"result": {

0 commit comments

Comments
 (0)