uber / causalml

Uplift modeling and causal inference with machine learning algorithms
Other
5.08k stars 780 forks source link

ImportError: cannot import name 'factorial' #219

Closed caizd1994 closed 3 years ago

caizd1994 commented 4 years ago

from causalml.inference.meta import BaseSRegressor, BaseTRegressor, BaseXRegressor, BaseRRegressor ----> 7 from scipy.misc import factorial

ImportError: cannot import name 'factorial

requirement.txt ask scipy==1.4.0 but where scipy >= 1.3 factorial is not in misc

Expected behavior update the package

ppstacy commented 4 years ago

Hi @caizd1994, thanks for using causalml and reporting this. In our most recent requiremnt.txt we are using scipy==1.14.1 because of the tensorflow requirement. I wasn't able to reproduce this bug, as shown in the below screenshot.

image

Could you try to remove any cached or previous installation of causalml and install it again?

# from somewhere not in the causalml source directory
$ pip uninstall causalml 
$ pip install --no-cache-dir -U causalml

Please let me know if it helps.

caizd1994 commented 4 years ago

when

from causalml.inference.meta import BaseXRegressor

show this error


ImportError Traceback (most recent call last)

in ----> 1 from causalml.inference.meta import BaseXRegressor /conda/envs/notebook/lib/python3.6/site-packages/causalml/inference/meta/__init__.py in ----> 1 from .slearner import LRSRegressor, BaseSLearner, BaseSRegressor, BaseSClassifier 2 from .tlearner import XGBTRegressor, MLPTRegressor, BaseTLearner, BaseTRegressor, BaseTClassifier 3 from .xlearner import BaseXLearner, BaseXRegressor, BaseXClassifier 4 from .rlearner import BaseRLearner, BaseRRegressor, BaseRClassifier, XGBRRegressor 5 from .tmle import TMLELearner /conda/envs/notebook/lib/python3.6/site-packages/causalml/inference/meta/slearner.py in 4 from scipy.stats import norm 5 from sklearn.dummy import DummyRegressor ----> 6 import statsmodels.api as sm 7 from copy import deepcopy 8 /conda/envs/notebook/lib/python3.6/site-packages/statsmodels/api.py in 14 from . import robust 15 from .robust.robust_linear_model import RLM ---> 16 from .discrete.discrete_model import (Poisson, Logit, Probit, 17 MNLogit, NegativeBinomial, 18 GeneralizedPoisson, /conda/envs/notebook/lib/python3.6/site-packages/statsmodels/discrete/discrete_model.py in 43 44 from statsmodels.base.l1_slsqp import fit_l1_slsqp ---> 45 from statsmodels.distributions import genpoisson_p 46 47 try: /conda/envs/notebook/lib/python3.6/site-packages/statsmodels/distributions/__init__.py in 1 from .empirical_distribution import ECDF, monotone_fn_inverter, StepFunction ----> 2 from .edgeworth import ExpandedNormal 3 from .discrete import genpoisson_p, zipoisson, zigenpoisson, zinegbin /conda/envs/notebook/lib/python3.6/site-packages/statsmodels/distributions/edgeworth.py in 5 import numpy as np 6 from numpy.polynomial.hermite_e import HermiteE ----> 7 from scipy.misc import factorial 8 from scipy.stats import rv_continuous 9 import scipy.special as special ImportError: cannot import name 'factorial' ![image](https://user-images.githubusercontent.com/34201050/88251232-bdf45800-ccdc-11ea-8e42-524815f25110.png)
ppstacy commented 4 years ago

Hi, it seems this problem actually coming from statsmodels. I also saw similar issue here been discussed. What's the statsmodels version you are using? Could you upgrade to statsmodels>=0.9.0? Thanks!

ppstacy commented 4 years ago

Hi @caizd1994, just want to check-in to see if you still have this issue? Thanks!

manojbalaji1 commented 3 years ago

forced upgrade of statsmodels fixes this issue and installing a 1.4.0 version of scipy too