Time Series Regression using a Raw Python Neural Network

I’ve been looking at time series regression recently. Just for fun I coded up an example using a raw Python (with the NumPy library for numerical functions) neural network. For my example I used a standard benchmark data set that has the total number of airline passengers for the 144 months from January 1949 through December 1960.

(Click image to enlarge)

I used a rolling window approach, with a window size of 4. This means that I used each consecutive four months to predict the next month. So the first data item is (1.12 1.18, 1.32, 1.29, 1.21). I normalized the raw data by dividing each passenger count by 100,000. So the first item means in months 1-4 there were 112,000, 118,000, 132,000, and 129,000 passengers. Those values are used to predict the passenger count for month 5, which is 121,000. The second item is (1.18, 1.32, 1.29, 1.21, 1.35) — the counts for months 2-5 are used to predict the count for month 6.

After I created my prediction model, I used it to print out the actual and predicted passenger counts. I dropped that data into Excel and made a graph. The model worked pretty well. Time series regression can be extremely complicated, but this was an interesting little exercise.

Advertisements
This entry was posted in Machine Learning. Bookmark the permalink.

3 Responses to Time Series Regression using a Raw Python Neural Network

  1. Peter Boos says:

    Do you put your coding experiments on github somewhere ?

    • No — not enough time. I code up hundreds of little demos just for fun, but don’t save any.

      • PGT-ART says:

        it doesnt cost time, it actually will quickly save you time.
        Git is very easy to use, you should ask someone around to help you into it.
        99% of the coders use it, with Git people might extend upon small little ideas (fork it), or improve upon your coding style, or improve upon your neural net ideas / designs.
        Or you could fork your own solutions with adjusted math (saving your time).
        The best thing would be that people could better follow you to get into neural nets.

        I have ideas on how you programmed something like this article, but if you used git perhaps it would turn out that my ideas are different, and could be combined with your ideas.

Comments are closed.