0

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

Lenue001
  • 17
  • 3
  • Does this answer your question? [fitting exponential decay with no initial guessing](https://stackoverflow.com/questions/3938042/fitting-exponential-decay-with-no-initial-guessing) – David Mar 28 '21 at 18:09

1 Answers1

0

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

K.Cl
  • 1,615
  • 2
  • 9
  • 18