Solved – Gaussian process with time series

forecastinggaussian processMATLABpythontime series

I am trying to apply Gaussian process to estimate the value of a sensor reading. I have the readings of the sensor for few years (hourly paced time series) so my data is an array of two columns the first one is the time the other one is the sensor reading at that time. I have tried to write the code of the Gaussian process but I have no idea how can I model the time as it is the input of the model, should I just use the hour as a number , so I end up with a repeated series of numbers between 0 and 23 ? should I use the UNIX time-stamp which is an integer but then I will end up with an increasing series of numbers? What is the best practice about handling this problem? In other words what is the input to the Gaussian process model when we deal with time series. If you can provide me with some code snippets in python or MATLAB that will be very appreciated.
And another question, Could you recommend a Python package to deal with the problem of forecasting time series using Gaussian processes.

Best Answer

In reverse order there are many decent GP libraries such as SKLearn, GPy, pyGPs, GPflow and so on.

Secondly your input is clearly the time and you can preprocess this as you see fit but you should understand the high level questions such as do I only care about the hour of the day? (In which case you could drop the date and keep only the 0-23 hours) or do you also want to model perhaps seasonal trends? (In which case unix time stamps could be useful)

What is important to understand is that GPS are more than just a smooth extrapolation technique - so you can encode how similar points in time are via your choice of kernel. So for example a daily trend might be encoded as a periodic kernel with period of one day. You can then add and multiply this to season periodic kernels, maybe add some noise and so on. This combination of kernel arithmetic creates distributions over the sum and product of function spaces. Check out for example http://www.cs.toronto.edu/~duvenaud/cookbook/ and https://github.com/jkfitzsimons/IPyNotebook_MachineLearning/blob/master/Just%20Another%20Kernel%20Cookbook....ipynb.