Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Linear Regression Equation in Python

I'm pretty new to Python and am trying to code something in Python that I have working in Excel.

Im trying to produce a Linear Regression Equation which takes two points on a graph and extrapolate unknown values.

In Excel I use the FORCAST feature.

My data is this

X Coordinate (Day) [1,37] Y Coordinate (Price) [1478.8,1421.2]

In Excel I can query an unknown day e.g 99 and it will estimate a Price of 1322 tased off the linear trend line.

All the examples I can find read in large datasets into dataframes and plot them into Matplotlib. Unfortunately I cant find any code that is simplified down to a little code function.

I think I need to use sklearn.linear_model (LinearRegression) but I think it wants X and Y data to be input via 2d arrays which is confusing me.

I'd really appreciate it if someone has the time to point me in the write direction

Thanks in advance

Pete

Comments