Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DeepIV econml estimator from notebook and fix flaky test #1091

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,511 changes: 53 additions & 1,458 deletions docs/source/example_notebooks/dowhy-conditional-treatment-effects.ipynb

Large diffs are not rendered by default.

21 changes: 6 additions & 15 deletions tests/causal_estimators/test_econml_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_backdoor_estimators(self):
)
# Checking that the CATE estimates are not identical
dml_cate_estimates_f = dml_estimate.cate_estimates.flatten()
assert pytest.approx(dml_cate_estimates_f[0], 0.01) != dml_cate_estimates_f[1]
assert pytest.approx(dml_cate_estimates_f[0], 0.001) != dml_cate_estimates_f[1]
# Test ContinuousTreatmentOrthoForest
orthoforest_estimate = model.estimate_effect(
identified_estimand,
Expand All @@ -71,7 +71,7 @@ def test_backdoor_estimators(self):
)
# Checking that the CATE estimates are not identical
orthoforest_cate_estimates_f = orthoforest_estimate.cate_estimates.flatten()
assert pytest.approx(orthoforest_cate_estimates_f[0], 0.01) != orthoforest_cate_estimates_f[1]
assert pytest.approx(orthoforest_cate_estimates_f[0], 0.001) != orthoforest_cate_estimates_f[1]

# Test LinearDRLearner
data_binary = datasets.linear_dataset(
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_backdoor_estimators(self):
},
)
drlearner_cate_estimates_f = drlearner_estimate.cate_estimates.flatten()
assert pytest.approx(drlearner_cate_estimates_f[0], 0.01) != drlearner_cate_estimates_f[1]
assert pytest.approx(drlearner_cate_estimates_f[0], 0.001) != drlearner_cate_estimates_f[1]

def test_metalearners(self):
data = datasets.linear_dataset(
Expand Down Expand Up @@ -190,22 +190,13 @@ def test_iv_estimators(self):
keras.layers.Dense(1),
]
)
deepiv_estimate = model.estimate_effect(
dmliv_estimate = model.estimate_effect(
identified_estimand,
method_name="iv.econml.iv.nnet.DeepIV",
method_name="iv.econml.iv.dml.DMLIV",
target_units=lambda df: df["X0"] > -1,
confidence_intervals=False,
method_params={
"init_params": {
"n_components": 10, # Number of gaussians in the mixture density networks
# Treatment model,
"m": lambda z, x: treatment_model(keras.layers.concatenate([z, x])),
# Response model
"h": lambda t, x: response_model(keras.layers.concatenate([t, x])),
"n_samples": 1, # Number of samples used to estimate the response
"first_stage_options": {"epochs": 25},
"second_stage_options": {"epochs": 25},
},
"init_params": {"discrete_treatment": False, "discrete_instrument": False},
"fit_params": {},
},
)
Expand Down