0
我想在代码中使用PyQt-Fit库,但遇到了麻烦。只是为了试验,我从包装主页复制了示例代码。pyqt_fit.CurveFitting示例抛出错误
这里是我运行代码:
import pyqt_fit
from pyqt_fit import plot_fit
import numpy as np
from matplotlib import pylab
x = np.arange(0,3,0.01)
y = 2*x + 4*x**2 + np.random.randn(*x.shape)
def fct(params, x):
(a0, a1, a2) = params
return a0 + a1*x + a2*x*x
fit = pyqt_fit.CurveFitting(x, y, (0,1,0), fct)
result = plot_fit.fit_evaluation(fit, x, y)
print(fit(x)) # Display the estimated values
plot_fit.plot1d(result)
pylab.show()
这是我得到的错误:
fit = pyqt_fit.CurveFitting(x, y, (0,1,0), fct)
TypeError: __init__() takes exactly 3 arguments (5 given)
Example code from the docs给出了同样的错误。
我试着用谷歌搜索我的问题,但我找不到一个工作的例子。
我需要更改以正确传递所有参数?
自我回答,因为它是一个真正的问题,我花了一段时间试图解决,并希望把该解决方案在那里。 – Scimonster