dowhy icon indicating copy to clipboard operation
dowhy copied to clipboard

effect_modifiers

Open wxl112 opened this issue 2 years ago • 3 comments

Describe the bug I'm trying to estimate the causal effect by calling the "econml" package and specified an "effect_modifiers" variables that is continuous value ,but also I want set the parameters "num_quantiles_to_discretize_cont_cols = 6"

Steps to reproduce the behavior

dml_estimate = model.estimate_effect(identified_estimand, method_name="backdoor.econml.dml.DML",
                                     control_value = 0,
                                     treatment_value = 1000,
                                     effect_modifiers=['solar_radiation'],
                                 target_units = 'ate',#lambda df: df["diffusion_conditions"]==1,  # condition used for CATE
                                 confidence_intervals=False,
                                     num_quantiles_to_discretize_cont_cols = 6,
                                method_params={"init_params":{
                                                              'model_y':GradientBoostingRegressor(),
                                                              'model_t': GradientBoostingRegressor(),
                                                              "model_final": LassoCV(fit_intercept=False),
                                                              'featurizer':PolynomialFeatures(degree=1, include_bias=True)
                                                              },
                                                "fit_params":{
                                                    'inference':BootstrapInference(n_bootstrap_samples=100, n_jobs=-1),}
                                               })

TypeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_3380\140799330.py in 25 }, 26 "fit_params":{ ---> 27 'inference':BootstrapInference(n_bootstrap_samples=100, n_jobs=-1),} 28 }) 29 print(dml_estimate)

TypeError: estimate_effect() got an unexpected keyword argument 'num_quantiles_to_discretize_cont_cols'

Expected behavior I really expected i would have report behavior like below: image

Version information:

  • DoWhy version [e.g. 0.7]

Additional context Add any other context about the problem here.

wxl112 avatar Nov 18 '22 08:11 wxl112

Thanks for raising this @wxl112 . We do not currently support this parameter for econml estimators. Will plan to add it for the next release. For now, you may discretize the continuous effect modifiers before passing the data to DoWhy.

amit-sharma avatar Nov 24 '22 06:11 amit-sharma

thanks for taking your time to answer the question! all the best!regard!

wxl112 avatar Nov 29 '22 08:11 wxl112

It looks to me that this would work as long as the parameter is provided as extra_args? The EconML estimator: https://github.com/py-why/dowhy/blob/97e6bdc3db137280fdb8812dfba34de14a248c72/dowhy/causal_model.py#L307-L313 does have this as an argument: https://github.com/py-why/dowhy/blob/97e6bdc3db137280fdb8812dfba34de14a248c72/dowhy/causal_estimators/linear_regression_estimator.py#L32

Padarn avatar Dec 18 '22 08:12 Padarn