fp.append(np.polyfit(train_x, train_y, 2))
f.append(np.poly1d(fp))
print(np.poly1d(fp))
threshold = fsolve(f, 50)
The above code finds x values for y=50 successfully. But when I try to do the same for the fitted exponential function, I can't understand how to do that.
def f_exp(x, a, b, c):
y = a * np.exp(-b * x) + c
return y
popt, pcov = curve_fit(f_exp, train_x, train_y)
print(popt)
threshold = fsolve(f_exp, 50) fails with :TypeError: f_exp() missing 3 required positional arguments: 'a', 'b', and 'c'
if I add *popt then I get
threshold = fsolve(f_exp(*popt), 50) fails with: TypeError: f_exp() missing 1 required positional argument: 'c'
I assume that I need to add x value, but it's the value I'm trying to find... Anyway, adding some value instead of x, leads to another error:
threshold = fsolve(f_exp(1, *popt), 50) fails with: TypeError: 'numpy.float64' object is not callable