Fix S-learner estimate_ate DataFrame handling and return shape (#1026) - #1031
Conversation
jeongyoonlee
left a comment
There was a problem hiding this comment.
docs/examples/meta_learners_with_synthetic_data_multiple_treatment.ipynb still passes the removed return_ci to BaseSRegressor.estimate_ate(), so six cells now raise TypeError. The S-learner ATE section appears twice in the notebook, so each of these is duplicated:
ate_s = learner_s.estimate_ate(..., return_ci=False, bootstrap_ci=False)— lines 153 / 2430ate_s, ate_s_lb, ate_s_ub = learner_s.estimate_ate(..., return_ci=True, bootstrap_ci=False)— 215 / 2524ate_s_b, ate_s_lb_b, ate_s_ub_b = learner_s.estimate_ate(..., return_ci=True, bootstrap_ci=True, ...)— 280 / 2596
The last two only need return_ci dropped. The first is a point-estimate-only demo with no equivalent after this change — the following cell displays ate_s, which is now a 3-tuple — so please either drop that cell pair or index the ATE out. Re-run the notebook afterwards so the stored outputs match.
Minor: docs/examples/feature_interpretations_example.ipynb ends a cell with slearner.estimate_ate(X=X, treatment=w_multi, y=y) on a BaseSRegressor; its stored output is now stale (array → 3-tuple).
|
I’ve updated both affected notebooks to remove the deprecated return_ci usage and handle the new (ate, lb, ub) return consistently. The changes are in commit 4cae40d. Full notebook execution wasn’t possible locally due to the missing Cython _criterion extension, but the affected cells were updated surgically without unrelated output changes. |
Proposed changes
Fixes #1026.
This PR fixes two issues in
BaseSLearner.estimate_ate:KeyError: (0, 0)whenLRSRegressor.estimate_ate()is called with a pandas DataFrame.BaseSLearner.estimate_ate()consistently return(ate, lb, ub), matching the other meta-learners.The statsmodels parameters and confidence intervals are converted to NumPy arrays before positional indexing.
Tests were updated to reflect the consistent S-learner return signature, and a regression test was added for DataFrame input.
Before & After
Test
Types of changes
Checklist
Further comments
The
return_ciargument forBaseSLearner.estimate_ate()was removed so that S-learners follow the sameestimate_ate()return convention as the other meta-learners.The original DataFrame failure was reproduced against the parent commit and verified as fixed. CI passes on Python 3.11 and 3.12, and lint checks pass.