Skip to content
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5495caa
Removed datacollector from surrogate assisted
jmafoster1 Feb 17, 2025
b8ace8e
Removed data collector from causal test suite
jmafoster1 Feb 17, 2025
2ceb654
Removed datacollector from testing
jmafoster1 Feb 17, 2025
bb70338
Removed data collection tests
jmafoster1 Feb 17, 2025
736cf6d
Removed data collector from metamorphic relation
jmafoster1 Feb 17, 2025
b3b5261
removed data collector classes
jmafoster1 Feb 17, 2025
73eb5f1
Removed unnecessary methods and arguments from metamorphic relation
jmafoster1 Feb 17, 2025
127a2f4
Added experimental estimator to keep functionality of experimental da…
jmafoster1 Feb 17, 2025
4b7de4c
pylint
jmafoster1 Feb 17, 2025
a80ccef
pylint
jmafoster1 Feb 17, 2025
9cfff7d
codecov
jmafoster1 Feb 17, 2025
2d85097
Clarified experiemental estimator test.
jmafoster1 Feb 17, 2025
b9d2504
fixed pytest error
jmafoster1 Feb 17, 2025
1f1b8ab
Merge branch 'main' of github.com:CITCOM-project/CausalTestingFramewo…
jmafoster1 Feb 17, 2025
5b78c16
pylint
jmafoster1 Feb 17, 2025
ee98a2a
Updated docs
jmafoster1 Feb 17, 2025
7e33f80
fix: schematic diagram on homepage
f-allian Feb 17, 2025
61d1e3d
fix: remove mentions of data collector
f-allian Feb 17, 2025
9dd94f8
fix: misc typos
f-allian Feb 17, 2025
bedf769
add: note about 32-bit systems
f-allian Feb 17, 2025
3310bbe
Removed all mention of the causal test engine
jmafoster1 Feb 18, 2025
2786fdc
Fixed metamorphic relation
jmafoster1 Feb 18, 2025
c38706d
Fixed default behaviour of MR generation
jmafoster1 Feb 18, 2025
9a82172
Pylint
jmafoster1 Feb 18, 2025
1cef1fb
Examples
jmafoster1 Feb 18, 2025
78d1c3d
causal test case
jmafoster1 Feb 18, 2025
6071bd3
Reworked examples
jmafoster1 Feb 18, 2025
a15e15b
Removed causal test suite from poisson
jmafoster1 Feb 18, 2025
4b14212
Tests passing again
jmafoster1 Feb 18, 2025
31a70b1
Removed causal test suite
jmafoster1 Feb 18, 2025
7c0f0f2
Removed abstract causal test case + pylint
jmafoster1 Feb 18, 2025
e559295
Removed Z3
jmafoster1 Feb 18, 2025
0c55a82
pylint
jmafoster1 Feb 18, 2025
aaa18df
pylint
jmafoster1 Feb 18, 2025
67c973a
metamorphic relation codecov
jmafoster1 Feb 18, 2025
77ac1b8
causal dag coverage
jmafoster1 Feb 18, 2025
b86c584
All the tests pass and got rid of JSON front
jmafoster1 Feb 20, 2025
4d48785
IPCW outcome is now an output
jmafoster1 Feb 20, 2025
db5b8b8
pylint
jmafoster1 Feb 20, 2025
0af5898
pylint
jmafoster1 Feb 20, 2025
c86fcec
pylint
jmafoster1 Feb 20, 2025
26f814e
Forgot to save
jmafoster1 Feb 20, 2025
949c17d
Removed the docs for the deprecated frontends
jmafoster1 Feb 20, 2025
28c99b7
Removed test csv output
jmafoster1 Feb 20, 2025
98016cc
Merge branch 'main' into jmafoster1/remove-data-collector
f-allian Feb 26, 2025
b462aa1
Removed all mention of data collection and json front end
jmafoster1 Feb 27, 2025
15fa8ee
Merge branch 'jmafoster1/remove-data-collector' of github.com:CITCOM-…
jmafoster1 Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
161 changes: 0 additions & 161 deletions causal_testing/data_collection/data_collector.py

This file was deleted.

9 changes: 5 additions & 4 deletions causal_testing/estimation/abstract_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import pandas as pd

from causal_testing.testing.base_test_case import BaseTestCase

logger = logging.getLogger(__name__)


Expand All @@ -29,22 +31,21 @@ class Estimator(ABC):

def __init__(
# pylint: disable=too-many-arguments
# pylint: disable=R0801
self,
treatment: str,
base_test_case: BaseTestCase,
treatment_value: float,
control_value: float,
adjustment_set: set,
outcome: str,
df: pd.DataFrame = None,
effect_modifiers: dict[str:Any] = None,
alpha: float = 0.05,
query: str = "",
):
self.treatment = treatment
self.base_test_case = base_test_case
self.treatment_value = treatment_value
self.control_value = control_value
self.adjustment_set = adjustment_set
self.outcome = outcome
self.alpha = alpha
self.df = df.query(query) if query else df

Expand Down
18 changes: 10 additions & 8 deletions causal_testing/estimation/abstract_regression_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from causal_testing.specification.variable import Variable
from causal_testing.estimation.abstract_estimator import Estimator
from causal_testing.testing.base_test_case import BaseTestCase

logger = logging.getLogger(__name__)

Expand All @@ -22,23 +23,22 @@ class RegressionEstimator(Estimator):
def __init__(
# pylint: disable=too-many-arguments
self,
treatment: str,
base_test_case: BaseTestCase,
treatment_value: float,
control_value: float,
adjustment_set: set,
outcome: str,
df: pd.DataFrame = None,
effect_modifiers: dict[Variable:Any] = None,
formula: str = None,
alpha: float = 0.05,
query: str = "",
):
# pylint: disable=R0801
super().__init__(
treatment=treatment,
base_test_case=base_test_case,
treatment_value=treatment_value,
control_value=control_value,
adjustment_set=adjustment_set,
outcome=outcome,
df=df,
effect_modifiers=effect_modifiers,
alpha=alpha,
Expand All @@ -53,8 +53,10 @@ def __init__(
if formula is not None:
self.formula = formula
else:
terms = [treatment] + sorted(list(adjustment_set)) + sorted(list(effect_modifiers))
self.formula = f"{outcome} ~ {'+'.join(terms)}"
terms = (
[base_test_case.treatment_variable.name] + sorted(list(adjustment_set)) + sorted(list(effect_modifiers))
)
self.formula = f"{base_test_case.outcome_variable.name} ~ {'+'.join(terms)}"

@property
@abstractmethod
Expand Down Expand Up @@ -104,7 +106,7 @@ def _predict(self, data=None, adjustment_config: dict = None) -> pd.DataFrame:

x = pd.DataFrame(columns=self.df.columns)
x["Intercept"] = 1 # self.intercept
x[self.treatment] = [self.treatment_value, self.control_value]
x[self.base_test_case.treatment_variable.name] = [self.treatment_value, self.control_value]

for k, v in adjustment_config.items():
x[k] = v
Expand All @@ -116,5 +118,5 @@ def _predict(self, data=None, adjustment_config: dict = None) -> pd.DataFrame:
x = pd.get_dummies(x, columns=[col], drop_first=True)

# This has to be here in case the treatment variable is in an I(...) block in the self.formula
x[self.treatment] = [self.treatment_value, self.control_value]
x[self.base_test_case.treatment_variable.name] = [self.treatment_value, self.control_value]
return model.get_prediction(x).summary_frame()
16 changes: 9 additions & 7 deletions causal_testing/estimation/cubic_spline_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from causal_testing.specification.variable import Variable
from causal_testing.estimation.linear_regression_estimator import LinearRegressionEstimator
from causal_testing.testing.base_test_case import BaseTestCase

logger = logging.getLogger(__name__)

Expand All @@ -20,11 +21,10 @@ class CubicSplineRegressionEstimator(LinearRegressionEstimator):
def __init__(
# pylint: disable=too-many-arguments
self,
treatment: str,
base_test_case: BaseTestCase,
treatment_value: float,
control_value: float,
adjustment_set: set,
outcome: str,
basis: int,
df: pd.DataFrame = None,
effect_modifiers: dict[Variable:Any] = None,
Expand All @@ -33,7 +33,7 @@ def __init__(
expected_relationship=None,
):
super().__init__(
treatment, treatment_value, control_value, adjustment_set, outcome, df, effect_modifiers, formula, alpha
base_test_case, treatment_value, control_value, adjustment_set, df, effect_modifiers, formula, alpha
)

self.expected_relationship = expected_relationship
Expand All @@ -42,8 +42,10 @@ def __init__(
effect_modifiers = []

if formula is None:
terms = [treatment] + sorted(list(adjustment_set)) + sorted(list(effect_modifiers))
self.formula = f"{outcome} ~ cr({'+'.join(terms)}, df={basis})"
terms = (
[base_test_case.treatment_variable.name] + sorted(list(adjustment_set)) + sorted(list(effect_modifiers))
)
self.formula = f"{base_test_case.outcome_variable.name} ~ cr({'+'.join(terms)}, df={basis})"

def estimate_ate_calculated(self, adjustment_config: dict = None) -> pd.Series:
"""Estimate the ate effect of the treatment on the outcome. That is, the change in outcome caused
Expand All @@ -59,7 +61,7 @@ def estimate_ate_calculated(self, adjustment_config: dict = None) -> pd.Series:
"""
model = self._run_regression()

x = {"Intercept": 1, self.treatment: self.treatment_value}
x = {"Intercept": 1, self.base_test_case.treatment_variable.name: self.treatment_value}
if adjustment_config is not None:
for k, v in adjustment_config.items():
x[k] = v
Expand All @@ -69,7 +71,7 @@ def estimate_ate_calculated(self, adjustment_config: dict = None) -> pd.Series:

treatment = model.predict(x).iloc[0]

x[self.treatment] = self.control_value
x[self.base_test_case.treatment_variable.name] = self.control_value
control = model.predict(x).iloc[0]

return pd.Series(treatment - control)
Loading