Мне удалось создать экспоненциальную регрессию на основе некоторых данных из эксперимента. Тем не менее, я бы хотел, чтобы регрессия прекратилась, когда значения y начинают расти (около x = 42000 секунд). Смотрите прикрепленное изображение сюжета.
Это код на данный момент:
import matplotlib.pyplot as plt;
import numpy as np;
import pandas as pd
import scipy.optimize as opt;
# This is the function we are trying to fit to the data.
def func(x, a, b, c):
return a * b**x
dataC = pd.read_csv("yeastdata1cropped.txt")
data = pd.read_csv("yeastdata1.txt")
xdata = np.array(data.iloc[:,1])
ydata = np.array(data.iloc[:,0])
xdatac = np.array(dataC.iloc[:,1])
ydatac = np.array(dataC.iloc[:,0])
# Plot the actual data
plt.plot(xdata, ydata, ".", label="Data");
# The actual curve fitting happens here
optimizedParameters, pcov = opt.curve_fit(func, xdatac, ydatac);
# Use the optimized parameters to plot the best fit
plt.plot(xdata, func(xdata, *optimizedParameters), label="fit");
# Show the graph
plt.legend();
plt.show();
