py-why / dowhy

DoWhy is a Python library for causal inference that supports explicit modeling and testing of causal assumptions. DoWhy is based on a unified language for causal inference, combining causal graphical models and potential outcomes frameworks.

Home Page:https://www.pywhy.org/dowhy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Counterfactual Reasoning with Categorical Variables

rudi-mac opened this issue · comments

I have a observational dataset of continuous, boolean and categorical variables and my goal is to make "what-if" statements. I have fitted and refuted the graph using gcm.InvertibleStructuralCausalModel.

The nodes represented by categorical variables are assigned with "Classifier FCM" based on HistGradientBoostingClassifier. When I want to call the function gcm.counterfactual_samples, I get the following error:

AttributeError: 'ClassifierFCM' object has no attribute 'estimate_noise'

I assume this is somehow related to the noise terms. If I remove the categorical variables, it works.

Therefore, my question: How to make counterfactual statements from observational data in dowhy with categorical variables?

Please help!

Version information:

  • DoWhy version 0.11.1

Hi, for point-wise counterfactuals, we currently only support continuous variables (since one only obtains a distribution for categorical variables, not a point estimate). However, depending on the use case, you might want to consider using interventions instead, which also work with categorical variables: https://www.pywhy.org/dowhy/v0.11.1/user_guide/causal_tasks/what_if/interventions.html

This issue is stale because it has been open for 14 days with no activity.

Thanks a lot for the reply! This is very helpful!