【问题标题】:Python's powerlaw package: AttributeError: 'powerlaw_gen' object has no attribute 'Fit'Python 的幂律包:AttributeError: 'powerlaw_gen' object has no attribute 'Fit'
【发布时间】:2021-03-05 16:14:47
【问题描述】:

我正在尝试在 Python 上构建幂律图,但它会引发如下错误:

AttributeError: 'powerlaw_gen' 对象没有属性 'Fit'

即使我从另一个用户 (@AcCap) 于 2016 年在此论坛上发布的示例中选择了一个标准数据样本,现在它也引发了同样的错误。 python plot and powerlaw fit

这是采样代码:

import powerlaw
d=[6, 4, 0, 0, 0, 0, 0, 1, 3, 1, 0, 3, 3, 0, 0, 0, 0, 1, 1, 0, 0, 0, 3,2,  3, 3, 2, 5, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0, 0, 1,0, 1, 2, 0, 0, 0, 2, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1,3, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 2, 2, 3, 2, 1, 0, 0, 0, 1, 2]
fit = powerlaw.Fit(numpy.array(d)+1,xmin=1,discrete=True)
fit.power_law.plot_pdf( color= 'b',linestyle='--',label='fit ccdf')
fit.plot_pdf( color= 'b')

print('alpha= ',fit.power_law.alpha,'  sigma= ',fit.power_law.sigma)

有人知道吗?非常感谢!

【问题讨论】:

    标签: python power-law


    【解决方案1】:

    尝试先安装这个:

    pip install powerlaw==1.3.4

    我遇到了同样的错误,但这解决了它!

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 2018-02-05
      • 2020-04-26
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      • 2022-12-27
      • 2021-11-08
      相关资源
      最近更新 更多