LoginSignup
xshangtiao
@xshangtiao (syu kami)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

python RuntimeErrorフィッティング

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

このエラーの解決方法を教えてください。

コード

X = sato.loc[:,'time1']
y = sato.loc[:,'abs']

X = np.array(X)
y = np.array(y)

plt.scatter(X, y)

def f(x, C, k, l): # y = f(x)
return - C * k * np.exp(-k*x) / (1+ C * l * np.exp(-k * x))

C, k, l = curve_fit(f, X, y)[0]
print(f"y = - {C:.6}{k:.6}e^(-{k:.6}x) / (1+ {C:.6}{l:.6}e^(-{k:.6}x))")

x = np.arange(0, 1, 0.01)
y = f(x, C, k, l)
plt.plot(x, y,color = "red")
plt.show()

よろしくお願いします。

0

1Answer

Comments

  1. @xshangtiao

    Questioner
    すみませんsample_x, sample_yではなく、X,yでお願いします。申し訳ございません。
  2. @xshangtiao

    Questioner
    変更しておきました。

Your answer might help someone💌