Python Forum
how to predict next value taking in account several variables? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: how to predict next value taking in account several variables? (/thread-4519.html)



how to predict next value taking in account several variables? - drogontargaryen - Aug-22-2017

Hi Everyone, I am looking for a way to predict the next value of a Variable like 'linear regression' but taking in account other Variables that happens the same day:

Date Var1 Var2 Var3 Var4
02/07/2017 31 20 12 0
03/07/2017 43 12 16 3
04/07/2017 57 4 26 16
05/07/2017 37 15 31 19
06/07/2017 74 8 15 23
07/07/2017 75 22 16 38
08/07/2017 90 14 21 4
09/07/2017 59 7 10 12
10/07/2017 32 33 34 17
11/07/2017 40 18 25 6
12/07/2017 108 12 32 7
Legend:
Var1= Amount of cars in the street
Var2= Amount of people in the street
Var3= Amount of motorcycle in the street
Var4= Amount of dogs in the street

So how can I make a script in python that predicts next value of 'Var1' taking in account the Var1 history and also the history of Var2, Var3, Var4 ..

I think that if this can be done maybe I could gain more accuracy in the prediction.


RE: how to predict next value taking in account several variables? - Larz60+ - Aug-23-2017

you can fit the data to a curve. Once done the unknowns can found by applying against the curve
see: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html


RE: how to predict next value taking in account several variables? - ichabod801 - Aug-23-2017

That's called multiple linear regression, and requires matrix algebra and eigenvectors. It looks like the sklearn module can do it: https://stackoverflow.com/questions/11479064/multiple-linear-regression-in-python