Python错误“ AttributeError:模块'scipy.misc'没有属性'logsumexp'”

时间:2019-05-27 10:23:15

标签: python-3.x lifetimes-python

我正在尝试使用lifetimes标头从给定数据创建新近度,频率和T,但是它一直显示以下错误 AttributeError:模块'scipy.misc'没有属性'logsumexp'

from lifetimes.plotting import *
from lifetimes.utils import *
from lifetimes.estimation import *
data = summary_data_from_transaction_data(df, 'CustomerID','InvoiceDate', monetary_value_col='Sales', observation_period_end='2011-12-9')
print(data.head())

收到以下输出:

Traceback (most recent call last):
File "prj2.py", line 23, in <module>
from lifetimes.plotting import *
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\lifetimes\__init__.py", line 5, in <module>
from .fitters.beta_geo_fitter import BetaGeoFitter
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\lifetimes\fitters\beta_geo_fitter.py", line 9, in <module>
from autograd.scipy.special import gammaln, beta, gamma
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\autograd\scipy\__init__.py", line 7, in <module>
from . import misc
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\autograd\scipy\misc.py", line 7, in <module>
logsumexp = primitive(scipy.misc.logsumexp)
AttributeError: module 'scipy.misc' has no attribute 'logsumexp'

SciPy的版本为1.3.0 该代码应生成一个包含每个客户的新近度,频率和T的表格

2 个答案:

答案 0 :(得分:0)

降级为scipy == 1.1.0解决了该问题

答案 1 :(得分:0)

from scipy.misc import logsumexp更改为from scipy.special import logsumexp