# Multivariate Time series analysis: When is a CNN vs. LSTM appropriate?

I have multiple features in a time series and want to predict the values of the same features for the next time step. I have already trained an LSTM which is working okay, but takes a bit long to train.

So now my question: is it reasonable to use a CNN instead of an LSTM, even though it is a time series? Are there any indicators for when you should never switch to a CNN?

• You can use both- First few Conv1D layers and then few LSTM layers. You can also put the LSTM layers into Bidirectional layers. Another option is ConvLSTM2D layers which combines both CNN and LSTM into a single layer. You can also try to create an auto-encoder. There are multiple options and you should try them to see what fits your data best. Commented Jul 28, 2020 at 8:05

### Is it reasonable to use a CNN instead of an LSTM, even though it is a time series?

Yes, it is. Convolutional Neural Networks are applied to any kind of data in which neighboring information is supposedly relevant for the analysis of the data.

CNN are very popular with images, where data is correlated in space, and in video, where correlation happens both in space and time.

### Are there any indicators for when you should never switch to a CNN?

CNNs are limited in a sense: they have a rigid, forward structure.

If you are trying to perform:

• classification in sequences that have varying length ($$N$$ to $$1$$);
• trying to output another sequence which has no fixed proportion between their length and the length of the input ($$N$$ to $$M$$).

Simple feed-forward neural networks will fail (due to dimension inconsistency). So, in that case you should use a recursive neural network such as a LSTM.

A time series represents a temporal sequence of data - and generally for sequential data LSTM is the preferred DNN algorithm as it handles sequences much better . CNN generally becomes useful when you want to capture neighbourhood information like in an image.

having said this , please refer this article on how to use CNN for multivariate time series : [https://machinelearningmastery.com/how-to-develop-convolutional-neural-network-models-for-time-series-forecasting/#:~:text=%5B%5B101.67965%5D%5D-,Multivariate%20CNN%20Models,Multiple%20Parallel%20Series]

• "neighbourhood information like in an image" an image is a sequence (sequence = ordered data) Commented Jul 27, 2020 at 14:48

In general you need to think about how your data behave. If your data depends on its neighbours, CNN could be a solution. If it’s like a sequence and closely relate to its neighbours then RNN could be good. If you instead see you need longer memory across, then LSTM is required. So it all depends on what you are working on.