## Time Series Regression with a Neural Network

A time series regression problem is one where the goal is to predict a numeric values based on previous (in time) numeric values. For example, you might want to predict the closing price of a share of some company’s stock based on the closing price on the previous three days.

There are many ways to tackle a time series regression problem. One basic approach that uses a neural network is best explained with a concrete example. Suppose you want to predict the value of the sine function. Here are some values:

```x        sin(x)
----------------
0.0000	  0.0000
1.0000	  0.8415
2.0000	  0.9093
3.0000	  0.1411
4.0000	 -0.7568
5.0000	 -0.9589
6.0000	 -0.2794
etc.
```

You construct training data that looks like this:

```0.0000,  0.8415,  0.9093,  0.1411
0.8415,  0.9093,  0.1411, -0.7568
0.9093,  0.1411, -0.7568, -0.9589
0.1411, -0.7568, -0.9589, -0.2794
etc.
```

The first three values in each line are the predictors, and the fourth value is the target to predict. It’s hard to explain in words but if you examine the data you’ll see what’s going on. Notice that data points get duplicated in the training data file. You can avoid this but in my opinion it’s better to keep things simple, by using duplicate data points.

At this point you have a standard prediction problem and you can use a basic neural network.

The example here looks back in time three data points. Why three and not four? Basically, the number of points in time to look backwards is a free parameter and must be determined by trial and error.

The moral of the story is that analyzing a time series regression problem with a neural network is really mostly about converting data into a usable format. By the way, a related approach for time series regression is to use a recurrent neural network.