DoWhy 0.10.1中CausalModel无causal_estimator属性报错求助
解决DoWhy 0.10.1中
CausalModel无causal_estimator属性的问题 问题原因
DoWhy从0.9版本开始重构了核心API,做了两处关键变更:
- 原
CausalModel对象的causal_estimator属性被更名为estimator - 原估计器的
effect()方法被重命名为predict()(对齐scikit-learn的API风格)
这就是你在0.10.1版本中运行0.8版本代码时报错的原因。
修改后的代码
将原代码替换为以下内容即可正常运行:
# Compute predictions effect_pred = model.estimator.predict(earnings_interaction_test.drop(['true_effect', 'took_a_course'], axis=1)) # Get the true effect effect_true = earnings_interaction_test['true_effect'].values
补充说明
如果需要计算个体水平的因果效应,也可以使用estimate_individual_effects()方法,效果与原effect()方法一致:
effect_pred = model.estimator.estimate_individual_effects( earnings_interaction_test.drop(['true_effect', 'took_a_course'], axis=1) )
内容的提问来源于stack exchange,提问作者Briant
相关产品推荐
相关产品推荐

