SciPy curve_fit返回奇怪的拟合曲线

时间:2018-07-18 09:02:51

标签: python-3.x pandas scipy curve-fitting logistic-regression

我只是试图将一条曲线拟合到一堆看起来像逻辑函数的点上,结果就像是一条纠结的曲线。

这是代码:

from scipy.optimize import curve_fit

def logistic(v, m, n, a, t):
    return a * (1 + m * np.exp(-v/t))/(1 + n * np.exp(-v/t))

def power_curve_fit(xvalues, yvalues):

    xdata = xvalues
    ydata = yvalues

    popt, pcov = curve_fit(logistic, xdata, ydata)

    pc = pd.DataFrame()
    pc['wind_speed'] = xdata
    pc['power_gen'] = ydata 
    pc['Fit'] = logistic(xdata, *popt)

    plt.plot(xdata, logistic(xdata, *popt), 'red')
    plt.scatter(xdata, ydata, c='pink', marker='o')
    return pc

输出: enter image description here 有什么想法吗?

谢谢!

0 个答案:

没有答案