Skip to content

Commit 03f1bd8

Browse files
committed
Pylint
1 parent 05c5499 commit 03f1bd8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

causal_testing/estimation/iv_estimator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class InstrumentalVariableEstimator(Estimator):
1919

2020
def __init__(
2121
# pylint: disable=too-many-arguments
22+
# pylint: disable=duplicate-code
2223
self,
2324
treatment: str,
2425
treatment_value: float,
@@ -27,8 +28,6 @@ def __init__(
2728
outcome: str,
2829
instrument: str,
2930
df: pd.DataFrame = None,
30-
intercept: int = 1,
31-
effect_modifiers: dict = None, # Not used (yet?). Needed for compatibility
3231
alpha: float = 0.05,
3332
query: str = "",
3433
):
@@ -43,8 +42,7 @@ def __init__(
4342
alpha=alpha,
4443
query=query,
4544
)
46-
self.intercept = intercept
47-
self.model = None
45+
4846
self.instrument = instrument
4947

5048
def add_modelling_assumptions(self):

causal_testing/estimation/logistic_regression_estimator.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ def add_modelling_assumptions(self):
3434
self.modelling_assumptions.append("The outcome must be binary.")
3535
self.modelling_assumptions.append("Independently and identically distributed errors.")
3636

37+
def _predict(self, data=None, adjustment_config: dict = None) -> pd.DataFrame:
38+
"""Estimate the outcomes under control and treatment.
39+
40+
:param data: The data to use, defaults to `self.df`. Controllable for boostrap sampling.
41+
:param: adjustment_config: The values of the adjustment variables to use.
42+
43+
:return: The estimated outcome under control and treatment, with confidence intervals in the form of a
44+
dataframe with columns "predicted", "se", "ci_lower", and "ci_upper".
45+
"""
46+
if adjustment_config is None:
47+
adjustment_config = {}
48+
if set(self.adjustment_set) != set(adjustment_config):
49+
raise ValueError(
50+
f"Invalid adjustment configuration {adjustment_config}. Must specify values for {self.adjustment_set}"
51+
)
52+
53+
return super()._predict(data, adjustment_config)
54+
3755
def estimate_control_treatment(
3856
self, adjustment_config: dict = None, bootstrap_size: int = 100
3957
) -> tuple[pd.Series, pd.Series]:

causal_testing/estimation/regression_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _run_regression(self, data=None) -> RegressionResultsWrapper:
8888
self.model = model
8989
return model
9090

91-
def _predict(self, data=None, adjustment_config: dict = None) -> tuple[pd.Series, pd.Series]:
91+
def _predict(self, data=None, adjustment_config: dict = None) -> pd.DataFrame:
9292
"""Estimate the outcomes under control and treatment.
9393
9494
:param data: The data to use, defaults to `self.df`. Controllable for boostrap sampling.

0 commit comments

Comments
 (0)