我正在尝试运行生命线包,
import numpy as np
from scipy import stats
import pandas as pd
from scipy.special import logsumexp
from lifelines import KaplanMeierFitter, CoxPHFitter
from lifelines.statistics import logrank_test
结果证明
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-2f2a9dd88e46> in <module>
4 from scipy.special import logsumexp
----> 5 from lifelines import KaplanMeierFitter, CoxPHFitter
6 from lifelines.statistics import logrank_test
~/.virtualenvs/stats/lib/python3.7/site-packages/lifelines/__init__.py in <module>
12 from lifelines.fitters.aalen_johansen_fitter import AalenJohansenFitter
---> 13 from lifelines.fitters.log_normal_fitter import LogNormalFitter
14 from lifelines.fitters.log_logistic_fitter import LogLogisticFitter
~/.virtualenvs/stats/lib/python3.7/site-packages/lifelines/fitters/log_normal_fitter.py in <module>
4 import autograd.numpy as np
----> 5 from autograd.scipy.stats import norm
6 from lifelines.fitters import KnownModelParametericUnivariateFitter
~/.virtualenvs/stats/lib/python3.7/site-packages/autograd/scipy/__init__.py in <module>
6 try:
----> 7 from . import misc
8 except ImportError:
9 pass
~/.virtualenvs/stats/lib/python3.7/site-packages/autograd/scipy/misc.py in <module>
5 from autograd.numpy.numpy_vjps import repeat_to_match_shape
6
----> 7 logsumexp = primitive(scipy.misc.logsumexp)
8
9 def make_grad_logsumexp(ans, x, axis=None, b=1.0, keepdims=False):
AttributeError: module 'scipy.misc' has no attribute 'logsumexp'
我知道logumexp已从scipy.misc中删除,并放在scipy.special中。以前,有人建议将SciPy降级到1.1.0版本。但是,如果我从
更改代码会更容易logsumexp = primitive(scipy.misc.logsumexp)
到
logsumexp = primitive(scipy.special.logsumexp)
如果可能的话,我可以知道如何修改代码吗?该代码在Scipy.misc中还是在生命线中?