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.
https://www.pywhy.org/dowhy
MIT License
6.88k stars 915 forks source link

numpy.dual is dropped but it still occurs in dowhy #1181

Open wyycommu opened 1 month ago

wyycommu commented 1 month ago

When operating from dowhy import gcm, it reported: No module named 'numpy.dual'.

Details are below:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[26], line 1
----> 1 from dowhy import gcm

File d:\\PycharmProjects\\pythonProjectTest\\.venv\\Lib\\site-packages\\dowhy\\gcm\\__init__.py:12
     10 from .fitting_sampling import fit, draw_samples
     11 from .graph import StochasticModel, ConditionalStochasticModel, FunctionalCausalModel, DirectedGraph, is_root_node
---> 12 from .influence import arrow_strength, intrinsic_causal_influence
     13 from .stochastic_models import EmpiricalDistribution, BayesianGaussianMixtureDistribution, ScipyDistribution
     14 from .whatif import interventional_samples, counterfactual_samples, average_causal_effect

File d:\\PycharmProjects\\pythonProjectTest\\.venv\\Lib\\site-packages\\dowhy\\gcm\\influence.py:25
     23 from dowhy.gcm.shapley import ShapleyConfig, estimate_shapley_values
     24 from dowhy.gcm.stats import marginal_expectation
---> 25 from dowhy.gcm.uncertainty import estimate_entropy_of_probabilities, estimate_variance
     26 from dowhy.gcm.util.general import shape_into_2d, set_random_seed, is_categorical
     28 _logger = logging.getLogger(__name__)

File d:\\PycharmProjects\\pythonProjectTest\\.venv\\Lib\\site-packages\\dowhy\\gcm\\uncertainty.py:7
      1 \"\"\"Functions to estimate uncertainties such as entropy, KL divergence etc.
      2 
      3 Functions in this module should be considered experimental, meaning there might be breaking API changes in the future.
      4 \"\"\"
      6 import numpy as np
----> 7 from numpy.dual import det
      8 from scipy.special import digamma
      9 from scipy.stats import entropy

ModuleNotFoundError: No module named 'numpy.dual'"

numpy.dual is dropped from numpy since 1.20.0(https://numpy.org/doc/stable/release/1.20.0-notes.html#deprecation-of-numpy-dual)


dowhy version: 0.8

bloebp commented 1 month ago

Hi, can you try to update your DoWhy version? nump.dual is not used anymore in the newer DoWhy versions. The current version is 0.11.1.

wyycommu commented 1 month ago

My python version is not compatible, it installs dowhy 0.8. After changing py3.12 to py3.11, I can install latest dowhy. Thanks for your suggestion, it helps a lot !