简体   繁体   中英

exponential decay regression model in python

I have just started learning the sklearn module and have been importing data and finding the linear regression model and using it to predict more values.

I am now trying to find the relationship between the displacement of an engine and the mpg. but when I graphed it, it looks more like an exponential decay; how would I find the regression model for this graph Graph of engine displacement and mpg

Try this

from scipy.optimize import curve_fit
import numpy as np

def exp_decay(x, a, b, c):
    return a * np.exp(-x*b) + c

X = (your data)
Y = (your data)

popt, pcov = curve_fit(exp_decay, X, Y, p0=(1,1,1))

See the documentation here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM