Scipy Optimal parameters not found: Number of calls to function has reached maxfev = 800

狂风中的少年 提交于 2019-12-24 09:58:39

问题


Trying for the logarithmic fit on the dataset using the codes posted. I keep getting Optimal parameters not found: Number of calls to function has reached maxfev = 800. Can you help me 1. Resolve the error 2. If the equation I'm using is a good one for the current dataset 3. Suggest any alternative method?

Dataset  
      Years        Values
    0    2000      23.0
    1    2001      27.5
    2    2002      46.0
    3    2003      56.0
    4    2004      64.8
    5    2005      71.2
    6    2006      80.2
    7    2007      98.0
    8    2008     113.0
    9    2009     155.8
    10   2010     414.0
    11   2011    2297.8
    12   2012    3628.4
    13   2013   16187.8
    14   2014   25197.8
    15   2015   42987.8
    16   2016   77555.5
    17   2017  130631.9

X = np.array(df.Years, dtype = float)
y = np.array(df.Values, dtype = float)
def func(x, a, b, c):
    return a * np.exp(b * x) + c
popt, pcov = curve_fit(func, X, y)
plt.plot(X, y, 'ro', label="Original data")
plt.plot(X, func(X, *popt), label="Fitted Curve")
plt.legend(loc='upper left')
plt.show()

来源:https://stackoverflow.com/questions/51122688/scipy-optimal-parameters-not-found-number-of-calls-to-function-has-reached-maxf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!