PacktPublishing/Causal-Inference-and-Discovery-in-Python

dowhy version 0.11.1 - Incompatibilities, can be fixed ?

Closed this issue · 3 comments

First of all, congratulations on the book! It is a great work.

In parallel with reading, I am trying to run the .pynb in the updated version of dowhy under python 3.11.8, which is closer to my Data Science environment than the python 3.9, and 0.8 dowhy version.

Unfortunately, I am not able to fix the error in Chapter 7 and Chapter 8.

In chapter 7, the cell 21:

estimate = model.estimate_effect(
      identified_estimand=estimand,
      method_name='backdoor.econml.dml.DML',
      method_params={
          'init_params': {
              'model_y': GradientBoostingRegressor(),
              'model_t': GradientBoostingRegressor(),
              'model_final': LassoCV(fit_intercept=False),
          },
          'fit_params': {}}
  )
  
  print(f'Estimate of causal effect (DML): {estimate.value}')

leads to an ImportError: "Error loading econml.dml.DML. Double-check the method name and ensure that all econml dependencies are installed.".

which looks similar to the cell 5 which also try to use DML:

# Get estimate (DML)
estimate_dml = model.estimate_effect(
    identified_estimand=estimand,
    method_name='backdoor.econml.dml.DML',
    method_params={
        'init_params': {
            'model_y': GradientBoostingRegressor(),
            'model_t': GradientBoostingRegressor(),
            'model_final': LassoCV(fit_intercept=False),
        },
        'fit_params': {}}
)  

Complaining that: "ImportError: Error loading econml.dml.DML. Double-check the method name and ensure that all econml dependencies are installed."

Any clue/ guidance on how to fix this?

Hi @Slepetys

It seems that you're missing econml installation in your environment.

You can install it using pip install econml or via conda.

Please let me know if that solved the problem for you.

Thank you @AlxndrMlk , it worked. I had the impression that econml would be automatically installed with dowhy. Also, I tried to install it with conda together with dowhy, and it didn´t work, but it worked using pip.

Great, I am happy to hear it worked @Slepetys

Wish you a joyful journey with the remaining part of the book & code!