I have a data like below and I would like to fit a straight line (like a Black line) ignoring the points following ceiling effect. Then I would like to predict Y values of these points using the slope and find the expected difference due to ceiling effect.
I tried using following code from other stackoverflow question but it does not do a good job at ignoring points with ceiling effect.
from scipy.optimize import curve_fit
def f(x, A, B): # this is your 'straight line' y=f(x)
return A*x + B
popt, pcov = curve_fit(f, x, y) # your data x, y to fit
Please feel free to provide any ideas or suggestions. Thank you.