# neural networks - Inputting a time series to a classification NN

I have a simple ANN that does the job of classification between two labels-:

• Sick
• Healthy

What I want to do is that input patient data ie. heart rate(ECG), EEG, etc which will be in the form of a time series.

How is that done in a neural network ? Is the time series unrolled into a input vector if so do each neuron handles one sample of that time series ?

Basically how is the input transformation done ?

To better understand this take the example of the traditional IRIS classification example. Lets say that instead of inputting petal length or sepal length you would input 4 time series in place of them and get a classification class as output.

Note I am not trying to do time series forecasting.

A few options:

• Split the time series into several fixed length windows and manually extract some features from each window. That way your input always has the same length and can be fed to any standard classification algorithm (neural nets, decision trees,...).

• Split the time series into several fixed length windows and feed them directly to a convolutional neural network. CNNs basically do the feature extraction on their own.

• Look into algorithms that naturally consume time series data - like recurrent neural networks (especially LSTMs).

This seems to be a typical case for using Dynamic Time Warping nearest neighbour classification.

### Euclidean Distance

Lets say we have two time series that have the same length and equi-distant timestamps. We number the timestamps with the numbers 1 to $n$, where $n$ is the number of values in the series. From now on those numbers are meant when talking about the timestamps. The euclidean distance of the time series is calculated by, for each timestamp, subtracting the two values and taking the square. All those squared values are added up and the square root is taken. The euclidean distance has the issue that if parts of the signals are a little distorted in time, it is not really representative for what is really going on. Imagine two spikes that a little earlier/later from each other. The two signals look otherwise the same, but would be considered to be very different - more different than a signal with a spike would be compared to a signal which just a flat line. Imagine that those spikes are hart beats and it becomes pretty clear, right?

### Dynamic Time Warping

Dynamic Time Warping is a distance between time series. It measures the distance of two time series by allowing the timestamps of the two signals to be moved a little left or right. So the two spikes from earlier would be aligned on each other and the signals would be considered to be very similar, as they should be.

### DTW nearest neighbour

Image you have some time series that belong to one class and some times series that belong to another class and you have them labelled. Now you have new time series that you want to classify. The brute force DTW NN is to simply calculate the distance of your new time series to all the labelled time series and determine that your new series has the same class as the labelled series that has the smallest DTW distance to it. There are methods to make that concept really fast. If you want to learn them check out the material below. It also explains that even though the DTW NN concept sounds simple, it is really hard to beat in terms of result for this type of application.

### More details

For more study check out the slides, especially slide 49 and the video lectures for which they were made.

• The answer is extremely short, can you please expand? – forecaster Aug 28 '17 at 12:44
• @forecaster: Better? (If so, I would look forward to a +1 :-).) – Make42 Aug 28 '17 at 14:16