## Time Series Regression using a C# Neural Network

I wrote an article titled “Time Series Regression using a C# Neural Network” in the October 2017 issue of Microsoft MSDN Magazine. See https://msdn.microsoft.com/en-us/magazine/mt826350.

I started my article by noting that the goal of a time-series regression problem is to make predictions based on historical time data. For example, if you have monthly sales data (over the course of a year or two), you might want to predict sales for the upcoming month. Time-series regression is usually very difficult, and there are many different techniques you can use.

In my article, I tackle a standard time series problem where the data is total international airline passengers per month, from January 1949 through December 1960 (144 months). I used a “rolling window” approach where the raw data is configured to look like this:

```1.12, 1.18, 1.32, 1.29, 1.21
1.18, 1.32, 1.29, 1.21, 1.35
1.32, 1.29, 1.21, 1.35, 1.48
1.29, 1.21, 1.35, 1.48, 1.48
1.21, 1.35, 1.48, 1.48, 1.36
. . .
6.06, 5.08, 4.61, 3.90, 4.32
```

Each value is the number of passengers in 100,000s. Each set of four consecutive months is used to predict the passenger count for the next month. The window size of four is arbitrary and in general you must use trial and error to determine a good window size for each problem.

I used a neural network approach. In essence, this is just a normal regression problem (i.e., the goal is to predict a single numeric value) with specially formed training data.

The prediction model worked pretty well:

Time series regression is very challenging. This simple example is relatively easy, but real-life time series problems are among the most difficult problems in all of machine learning.

The Time Machine (1960)

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

### 4 Responses to Time Series Regression using a C# Neural Network

1. PGT-ART says:

Nice article and again a great topic, i would go for that approach as well. Although i would also wonder. How about creating neural net nodes that form a loop, ea 4 extra out put nodes, would output their data back into 4 extra input nodes.
So at the input side (4 times new data + 4 previous neural net results from the 4 extra outputs)
Without having any constrains on those outputs.. i wonder if such loops would result in memory alike behaviour. I’ve not tried your code yet, i hope the airplane data is in it too, it would be nice to test that.

2. Peter Boos says:

The source code hyper-link isnt working, may i suggest to put your code on Git ?
Try GIT width sourcetree its free, its like having you code stored in an archive cloud.