{'fraction_non_alphanumeric': 0.03576509836628563, 'fraction_numerical': 0.008904479222881814, 'mean_word_length': 4.662083333333333, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Spatial-Temporal Decomposition Based Deep Neural Network for Time Series Forecasting

Spatial time series forecasting problems arise in a broad range of applications, such as environmental and transportation problems. These problems are challenging because of the existence of specific spatial, short-term and long-term patterns, and the curse of dimensionality. In this paper, we propose a deep neural network framework for large-scale spatial time series forecasting problems. We explicitly designed the neural network architecture for capturing various types of patterns. In preprocessing, a time series decomposition method is applied to separately feed short-term, long-term and spatial patterns into different components of a neural network. A fuzzy clustering method finds cluster of neighboring time series based on similarity of time series residuals; as they can be meaningful short-term patterns for spatial time series. In neural network architecture, each kernel of a multi-kernel convolution layer is applied to a cluster of time series to extract short-term features in neighboring areas. The output of convolution layer is concatenated by trends and followed by convolution-LSTM layer to capture long-term patterns in larger regional areas. To make a robust prediction when faced with missing data, an unsupervised pretrained denoising autoencoder reconstructs the output of the model in a fine-tuning step. The experimental results illustrate the model outperforms baseline and state of the art models in a traffic flow prediction dataset.


Introduction and Literature Review
Time series data arise in broad areas, such as engineering, medicine, finance, and economics. Various types of statistical and machine learning techniques have been applied on time series analysis. Recently, several new scalable time series analyses have been studied, such as forecasting [1], anomaly detection [2], classification [3] and clustering [4]. They illustrated the performance gains of these works over traditional time series techniques on large-scale problems. Moreover, spatial time series problems arise when there is a spatial dependency between neighboring time series. Spatial-temporal data arise in diverse areas of power grids [5], load demand forecasting [6], weather forecasting [7], smart city applications [8], and transportation systems, such as traffic flow forecasting [9], [10].
Traffic flow prediction is one of the essential components of Intelligent Transportation Systems and one of the most challenging spatial-temporal problems, because of recurrent and non-recurrent patterns and the physical dynamics involved. Traffic flow prediction can assist travelers to make better decisions and improve traffic management, while decreasing traffic congestion and air pollution. Recently, smart devices increase the role of traffic flow prediction problems in our daily lives, which help people planning their travel and find the most efficient routes. With the advent of new sensing, computing and networking technologies, such as cameras, sensors, radars, inductive loops and GPS devices, a large volume of data are readily available [11]. These increasingly large data sets means that big data and techniques to handle these data plays a key role in the success of future transportation systems [12]. Hence, to improve the performance of transportation systems, researchers are motivated to take advantage of new spatial-temporal data-driven techniques and design scalable algorithms capable of processing large volume of data, such as deep neural networks , [1], [13].

Background
Starting in the 1970's with the original work of Gazis and Knapp [14] there have been many studies applying time series forecasting techniques to traffic flow prediction problem, including parametric techniques, such as auto-regressive integrated moving average (ARIMA) [15] and Seasonal-ARIMA [16], and statistical techniques, such as Bayesian analysis [17], Markov chain [18] and Bayesian networks [19]. However, there are several limitations on the models, because of prior assumptions, lack of handling missing data, noisy data, outliers, and the curse of dimensionality. Shallow architecture neural networks are capable of high dimension data, but cannot capture a high order computational complexity. With superior performance of deep neural networks on large-scale problems, they became an alternative technique applied on large-scale multi-variate time series forecasting problems.
Recently, there have been several attempts to design deep learning models for multi-variate time series forecasting problems. The primary work related to ours proposes a stacked autoencoder (SAE) model to learn traffic flow features and illustrate the advantage of SAE model versus Multi-layer Perceptron [1]. In [20], they propose stacked autoencoders with multi-task learning at the top layers of the neural network. A Deep Belief Network(DBN) composed by layers of restricted boltzman machine is proposed [21]. In [22], an ensemble of four categories of fully connected neural network is applied on time series forecasting problem. In [23], an ensemble of DBN with Support Vector Regression for aggregation of outputs is proposed for time series forecasting problem. However, in fully connected neural networks, the size increases exponentially with increasing input size, therefore the convergence of the model is computationally expensive and challenging. Several other neural network layers have been proposed to reduce the computational time and capture patterns in high order computationally complex temporal datasets.
Convolutional Neural Networks (CNN) extract features of various types of input data, such as images, videos, and audio. Weight sharing, the main feature of CNN, reduces the number of parameters in deep neural network models. These properties improve performance of learning algorithms by reducing complexity of parameters [24]. The performance of deep CNNs in multi-variate time series forecasting is examined; in [25], a spatial-temporal relation of traffic flow data is represented as images. A CNN model is used to train from images and forecast speed in large transportation networks. In [26], they studied image-like representation of spatial time series data using convolution layers and ensemble learning. A convolution layer consider spatial structure in a euclidean space, which can miss some information on graph-structure data [27]. As an alternative approach, following the work [28], spatial dependency is captured using bi-directional diffusion convolutional recurrent networks [29]. They illustrate a graph-structured representation of time series data capture spatial relation among time series. Moreover, in the presence of temporal data, recurrent neural networks have shown great performance in time series forecasting [30]. The vanishing gradient in deep Multilayer perceptron and recurrent neural network problem is solved by employing a Long-Short Term Model (LSTM) [31], which significantly improves time series forecasting [32], traffic speed prediction [33] and traffic flow estimation with missing data [34].
While convolutional neural networks can exhibit excellent performance on spatial data, and recurrent neural networks have advantages on problems with temporal data; spatial-temporal problems combine both of these. In [35], they propose convolutional-LSTM layer for weather forecasting problem, in which consider spatiotemporal sequences. A convolutional deep learning model for multi-variate time series forecasting is proposed [36]. They propose explicit grouping of input time series and implicit grouping using error back-propagation. In [37], they use a CNN-LSTM model for downstream and upstream data to capture physical relationships among traffic flow data. A convolutional layer is followed by an LSTM layer for downstream and upstream traffic flow data. In [38], they illustrate a CNN and gated CNN followed by attention layers for spatialtemporal data. The capability of CNN-LSTM in learning spatial-temporal features are illustrated in above works. However, there is not any analysis on designing a neural network architecture with various components to separately capture spatial-temporal patterns.

Contribution
In the aforementioned works, spatial time series forecasting has been studied with the objective of proposing various types of convolution and recurrent neural network layers. However, spatial-temporal data have their specific patterns, which motivate us to use spatial and time series decomposition, and to explicitly consider various types of patterns in designing an efficient neural network architecture. There are some challenges in spatial-temporal data which should be considered in designing the deep neural network architecture. In spatial-temporal data, time series residuals are not only meaningless noise, but also related to physical properties and dynamical system of spatially dependent time series. Moreover, convolutional layers can capture spatial and short-term patterns, but sliding convolution kernels on spatial features miss network structure. In existence of long-term patterns, an LSTM layers shows great performance in forecasting problems because it can separately capture detrending data. Furthermore, a challenging problem is to address missing small spatial-temporal data in the time series forecasting problems.
In this paper, we address the problem of explicitly decomposing spatial-temporal patterns in designing a deep neural network and we illustrate its performance improvement on a large-scale traffic flow prediction problem. The contribution of the paper is described as follows: • We illustrate an approach for explicitly considering various types of patterns in a deep neural network architecture for a spatial multi-variate time series forecasting problem.
• We describe a Dynamic Time Warping-based clustering method and time series decomposition with the objective of finding compact regions with similar time series residuals.
• A multi-kernel convolution layer is designed for spatial time series data, to keep the spatial structure of time series data and extract short-term and spatial patterns. It follows by a convolution-LSTM component to capture long-term patterns from trends, and a pretrained denoising autoencoder to have robust prediction to missing data.
• The spatial and temporal patterns in traffic flow data is analyzed and the performance gains of the proposed model relative to baseline and state-of-art-the-art deep neural networks are illustrated for a traffic flow prediction, capturing meaningful time series residuals and a robust prediction to missing data.
The rest of the paper is as follows, in section II, we define the problem. In section III, the technical background of the proposed model are presented. In section IV, the proposed framework is illustrated, followed by the results of the work and conclusion discussed in section V.

Problem Definition
Time series data are a set of successive measurements, X i = {x 1 i , . . . , xt i }, where x t i is an observed variable at location i, time step t andt is the size of the time series. A sensor i gathers x t i with corresponding k features x t i = {x t,1 i , . . . , x t,k i }. A spatial-temporal data is a set of n multi-variate time series X = {x 1 , . . . , x n }, represented by a matrix of X ∈ R n×t×k , where n is the number of sensors, which gather spatial-temporal data X in synchronous time in a geographical area.
Given X as the set of all time series in a region, a spatial time series forecasting problem is cast as a regression problem. Given a time window of last w steps, and a horizon prediction h, the objective is to The time window is used to only consider a small portion of previous temporal data for predicting horizon data, while we expect the model to memorize the long-term patterns. In equation (1), an optimum parameter θ is the best model for forecasting time series data. In a neural network, θ is the weights of the model and the optimization algorithm minimizes the non-linear loss function f(., ., .) by solving following non-convex optimization problem, In this paper, given a spatial multi-variate time series data X, a deep neural network predicts X output ∈ R n×h×k , wherek is the number of output features, for input data X input ∈ R n×w×k . for i ← 2 to N do 9: end for 11: for j ← 2 to M do 12: end for 14: for i ← 2 to N do 15: for j ← 2 to M do 16: Return the nonlinear distance of two time series 21: end procedure

Technical Background
Here, we detail the core components of the proposed approach, including Fuzzy Hierarchical Agglomerative Clustering, Convolutional layers, Convolutional LSTM layers and Denoising Autoencoder.

Dynamic Time Warping
A Dynamic time warping (DTW) algorithm finds an optimal path between two time series. It compares each point of first time series with second one. Hence, similar patterns occurred in different time slots are considered similar. A dynamic programming method finds the optimal match [39]. Here, we illustrate the DTW for K-dimensional time series. Algorithm (1) finds the minimum distance between two K-dimensional time series with size of N and M.

Fuzzy Hierarchical Clustering
Given data points X = {x 1 , . . . , x n }, a fuzzy hierarchical clustering method finds a membership matrix C ∈ R n×c , where c is the number of clusters and C ij ∈ [0, 1] illustrates the distance of data points i to cluster j.
To apply a DTW-based clustering method, the main challenge is to compute the mean of a cluster addressed in [40], [41], [39], because the initial values impacts on the final results of the algorithm. Hence, we consider fuzzy hierarchical clustering method without a need to find the cluster mean. Following the work of [42], a complete-linkage is used for distances between clusters and a single-linkage is used for distance between points, and a point and a cluster. An algorithm (2) finds the membership matrix of sensors to clusters.
The matrix D is the set of distances between all pair of time series and clusters, and it is initialized by all distances between points. The function minDistance(.) finds the closest pair of elements (a, b) in the set D, which a and b can be points or clusters. The matrix C is the list of clusters and their members. The function updateClusters(., ., .) adds the selected pair of elements (a, b) to the list of clusters. This function merges a and b into a new cluster. The matrix A is the list of assigned points, when a point is assigned into one cluster. Based on a new formation of clusters, the function updateDistances(., ., .) finds the new distances between points and clusters. It updates the distance of all clusters and unassigned points to the new cluster. Moreover, it updates the fuzzy distance of all assigned points to the new cluster, and all points of new cluster to other clusters. The fuzzy distance between assigned point u, and a cluster c i obtains by using equations (2).
where d min u is the minimum distance of a assigned point to any of the clusters, µ(a, b) is membership value of assigned point u to the cluster c i , m is a fuzziness parameter, and the distance function d(., .) is based on single-linkage for each pair of points, or points and clusters, and complete-linkage for two clusters.

Algorithm 2 A DTW-based Fuzzy hierarchical Clustering on Spatial Time Series
N input time series and spatial distances List of assigned points C = {}; List of clusters and their members Return the list of clusters end procedure

Convolution Layer
A Convolutional layer uses three ideas of local receptive fields, shared weights and spatial subsampling; making them effective and efficient models for exploiting the local stationary on grid data [24]. Given an input matrix X ∈ R n×t×k , a 2-dimension convolution layer has a weight matrix W ∈ R a×b×k , called as a kernel, where a ≤ n and b ≤ t. A convolution multiplication X * W with strides s 1 and s 2 is obtained by sliding a kernel all over input matrix. The kernel is a shared weight which assume to have a locally stationary input data. Given X l as the input of layer l, a layer l + 1 obtains by X l+1 = σ(X l * W l + b) for an activation function σ(.) and bias vector b. Pooling layers X l+1 = maxPool(X l ) among successive convolution layers reduces size of hidden layers, while extract features in locally connected layers, which selects the maximum value in a matrix of sizeW ∈ R m×n , and reduce the dimension of layers divided by m and n.

Convolution-LSTM layer
A Long-Short Term Memory (LSTM) is a special recurrent neural network cell with powerful modelling of long-term dependencies [31]. A memory cell c t , input gate i t , output gate o t and forgot gate f t works together in hidden units h t . Given * convolution operator and • a Hadamard product, a convolution LSTM is as follows [35], A convolution-LSTM layer have same structure of convolution layers, but having LSTM cells. The gates prevent a gradient from vanishing quickly by storing it in memory. The convolution-LSTM layer has a input of X ∈ R w×a×b×k , where w is time windows and the matrix W ∈ R a×b×k is the spatial information on a grid of size a and b and each element W ij has k features.

Denoising Stacked Autoencoder
Given an input m-dimension data x ∈ R m , an autoencoders transforms input with a non-linear function [43]. The decoder generates z = σ(hW 2 +b 2 ), where z ∈ R m . In the training process the objective is to reconstruct x, by minimizing loss function L(., ., .), such as least square function, between x and z and obtaining optimum model parameters θ for all m input data as follows, Stacked autoencodersf(.) are a set of multiple autoencoder layers, in which the input of each layer is the output of previous layer [44]. The input data is corrupted with some noise, while the output remains unchanged. Adding noise to the input data and training the neural network to reconstruct the clean output, helps the neural network to learn robust features to noisy data. The noise can be added to the network using a dropout function in each layer h l+1 = dropout( σ( h l W l + b l ), α), in which randomly α percent of neurons are dropped in each round of training process. Unsupervised training of stacked autoencoders with the form of x =f(x) is capable of reconstructing the original data in the presence of noisy or missing data [45], [44], [46].

Methodology:
In this section, we describe the architecture of the proposed deep learning framework for spatial time series forecasting problem. The proposed framework is illustrated in Fig. (1). The network structure represents the distance between neighboring sensors, and the spatial-temporal data includes time series data for each sensor.

Preprocessing
A time series decomposition method is applied on input time series X ∈ R n×w×k , which generates three time series components of X = (S, T, R), which are seasonal, trends and residuals of time series, respectively. In spatial time series data, residuals can be different than only noise. For example, in a transportation network, time series residuals can be caused by the traffic evolution of the transportation network and they are meaningful patterns among neighboring time series, analyzed in section 5 experimental results.
To apply algorithm (2) on time series residuals, we consider a set G for geographically nearest neighbors of sensors. The algorithm updates single-linkage distances between two time series from set G; thus the clusters would not be distributed in a geographical area. Since some of the sensors might affect more than one regional cluster, the output of clustering algorithm finds fuzzy membership of each sensor to their similar clusters.
Each sensor x i has a membership to some cluster c j ∈ C. We say two time series x i and x j are similar, if two time series have similar patterns over some time shift, or have zero distance from each other. Hence, for a given distance function τ (., .), which we consider DTW, a fuzzy hierarchical clustering algorithm finds the cluster of sensors with similar residual time series by finding the clusters in which the distance of its members is minimized. To represent short-term similarity among neighboring time series, we used a rolling window on training data and getting average of corresponding DTW distances. A rolling window finds similarity between short-term time window of neighboring area. To reduce computational time, rolling window is only applied, when there are high interaction among neighboring time series. For example, in traffic flow data, the interaction among neighboring sensors increases peak hours and congestion time periods. Applying algorithm 2 with aforementioned modifications on spatial time series finds fuzzy clusters of time series based on DTW distance.

Neural Network Architecture
The details of the deep neural network is represented in Fig. 2. Time series residuals are the first input of the neural network, detrended and represented with a matrix of X ∈ R s×w×k . A convolutional component is applied to extract patterns from time series residuals. For a given set of time series X, a general convolution kernel slides on first and second axis. However, because the sensors can have a spatial structure, like sensors in a transportation network, sliding a kernel on sensors cannot keep the structure of the network. Moreover, each sensor's time series residuals are only dependent to small regions in the network. Hence, we propose a multikernel convolution layer, which receives the cluster set and residual time series data. A kernel W i for a cluster i, is described with weight matrix W i where W ij = 0, if j ∈ c i . In other words, the size of trainable variables for a kernel, corresponding to cluster i, is W i ∈ R |C i |,w,k . Only the sensors in cluster i, has a local connectivity to same residual time series. The kernel slides over time axis and obtain hidden units h i = pool( σ( R t i W i + b i )) for all i ∈ {1, . . . , |C|}, where pool is pooling layer. Several convolution-RELU-Pooling layers extracts shortterm and spatial patterns from the time series residuals in each neighborhood. The output of kernels are concatenated and connected to a fully-connected layer h l+1 = concat(FC(h l 1 ), . . . , FC(h l |C| )) and represented with a hidden layer h l+1 ∈ R w×s×v×1 , where v is the number of represented features in convolution layers and s is the total number of sensors.
The time series trends represent long-term patterns. The trends of time series T concatenate to h l+1 on the last axis, h l+2 = concat(h l+1 , FC(T), axis = 4) which results in h l+2 ∈ R w×s×v×2 . Unlike residuals which represent physical dynamics of the problem and there is only similarity between neighboring areas, trends can represent global changes in the spatial-temporal data. Hence, we consider LSTM cells to capture long-term patterns for the concatenated output of the extracted features of smaller regions. The model follows by a 2-dimension convolution LSTM layers. A 2-dimension convolution LSTM layer, described in section 3.4, receives an input h l+2 , and apply the convolution on the matrix of size (a = s, b ≤ v) with two channels. This convolutional layer has different architecture with the first multi-kernel convolution layer, that is, each neural cell is an LSTM cell and is applied on all input sensors. Some layers of convolution LSTM layers extract features from residuals and trends. Seasonal patterns represents repeated patterns for the given time horizon. The output is concatenated with seasonal patterns of time window {t − w, . . . , t + h}. It follows by a fully-connected layer. The output isȳ ∈ R s×h×k , where h is prediction horizon. The outputȳ consists of predicted values for all sensors in prediction horizon.
One of the challenges in spatial-temporal data is to have a robust prediction in existence of missing, noisy data. Hence, we consider an autoencoder layer in as the last component of the model. A denoising autoencoder decoder reconstructs the last outputȳ for each cluster. In the pretraining step, for a prediction horizon h and a cluster j, each denoising autoencoder decoder generates x = DA j (x), where x ∈ R s×h×k and drop out layer are between each successive layers. A denoising autoencoder component generates a predictionsȳ d = DA(ȳ). As the output of autoencoders is designed based on the clusters, there are some sensors x k ∈ c i ∩c j , i = j, where the fully-connected target layer FC t is connected to all common variables between denoising autoencoders with a linear activation function y output = FC t (DA 1 (ȳ), . . . , DA |C| (ȳ)). In the training process the objective is to minimize loss function L(., ., .), such as mean square error function, between y output and real values y, and obtaining optimum model parameters θ for input data using stochastic gradient descent,

Experimental Analysis
We illustrate the analysis and the performance of the proposed methodology on traffic flow data.

Data Set
We use traffic flow data from the Bay Area of California represented in Fig. 3 which is commonly used and available in PEMS [47]. The traffic flow has been gathered every 30 seconds and aggregated every 5 minutes in the dataset. Each sensor on highways of California has flow, occupancy and speed at a time stamp. A sensor is a loop detector device in mainline, off-ramp or on-ramps locations. In preprocessing, we selected 597 sensors which they have more than 90% observed values in the first six months of 2016.

Pattern analysis in traffic data
To illustrate the specific characteristics of traffic data arise from dynamic of traffic flow, we analyze the spatial, short-term and long-term patterns.
In Fig. 4, an additive time series decomposition of traffic flow data is illustrated for one station. Given a one day frequency, time series decomposition has similar, repeated (seasonal) daily patterns. Moreover, there are long-term weekly patterns, shown as trends T. The long-term patterns, such as seasonal and trends, arise from similar periodic patterns, generated outside of the highway network. In other words, they are related to origin-destination matrix of vehicles in the network. The residual patterns are not only random noise, but also the results of spatial and short-term patterns and related to the evolution of traffic flow or sudden changes in smaller regions of the network. Since they have more similar patterns for neighboring time series, illustrated in section 5.2.1.      In this section, we illustrate the results of fuzzy clustering applied on time series residuals. In Fig. 8, the DTW distance matrix shows residual similarity among neighboring sensors. The matrix shows the average DTW distance for peak times of training data, which has the highest dependency because of high values of occupancy. Each cluster would be obtained by comparing neighboring sensors. On the elements near to diagonal, the lowest distance values shows the similarity between neighboring values.

Fuzzy Hierarchical Clustering
After preprocessing of time series data, there are 597 sensors with complete data over a period of six months. The fuzzy clustering finds the membership of each sensor to clusters. In the fuzzy membership matrix, we consider threshold of 0.1. All the sensors which has a membership value of more than 0.1, they would be considered as the members of clusters. We also consider the average size of clusters to be less than 10 miles. The agglomerative clustering stops when the average become greater than 10. As the clustering is applied on mainline stations, we also added the on-ramp and off-ramp sensors to the closest mainline stations. The result of fuzzy heirarchial clustering method, has 64 clusters, where the average number of elements is 9.7 with standard deviation of 4.2 and minimum cluster size of 3 and maximum of 14. The length of smallest and largest cluster is 0.3 mile and 32.1 mile. And there are 53 sensors which appear in more than one cluster, nearly 10% of total sensors. To examine the relation between trends in one spatial area, using a rolling window, we obtain DTW distance of each pair of sensors. For a time window, we normalized trends, by subtracting all time stamp values from the last value. The average DTW distance is 0.7, for all pairs of sensors, which shows the high similarity of trends. By contrast, presented in section 5.2.1, the average DTW distance of time series residuals for all pair of sensors is 4.5, while applying the fuzzy clustering method on time series reduces the average DTW of clusters to 0.6. As a result, we only apply fuzzy clustering on time series residuals.

Results of comparison
Our model is demonstrated to outperform the state-of-the-art performance on the traffic flow prediction dataset. All models are trained using the ADAM optimizer [48]. The batch size of each iteration is set to 512 and 400 epochs. All experiments are implemented in TensorFlow [49] and conducted on NVIDIA Tesla K80 GPU. We used a grid search for finding the optimum deep neural network architectures which have the best performance and most efficient computational time.
The input matrix is I ∈ R s×w×k , where the number of sensors is s = 597, the time window is w = 6, and there are k = 3 features, including flow, occupancy and speed. For MLP, LSTM, CNN and the proposed multikernel CNN-LSTM models, the input dimension is reshaped to have a appropriate dimensions, described in model details section 5.4.2. For all models the data transform into range of [0, 1]. For the models without time series decomposition component, including MLP, LSTM and CNN, we transform the data into stationary data by subtracting all input values from the value at time step t, while detrending of the models with time series decomposition components is as follows. The residual time series is stationary. To feed trends and seasonal components to a neural network, we make them stationary by subtracting each time window from its last value S t and T t . To recover the output, we add the predicted value to sum of S t and T t . The output matrix is O ∈ R s×h×k , where the size of horizon h = 4 for 15-min, 30-min, 45-min and 60-min prediction in the result tables.

Baseline models
As it is illustrated in primary traffic flow prediction studies, the traffic flow patterns are similar in same hours and weekdays. The first baseline model (Ave-weekday-hourly) is to use average of traffic flow of each station as a time-table for each time t, given a weekday. The short-term prediction for each sensor is obtained by using average values in training data. The second baseline model (current value) is to use current value of traffic flow x t for short-term prediction x t+h .

State-of-the-Art Neural Network Models
In this section, we describe the implemented neural network models. A Multi-layer perceptron (MLP) with three fully connected layers and Xavier initialization [50], RELU activation function, and (500,300, 200) hidden units is used. A deep belief network (DBN) with greedy layer wise pretraining of autoencoders finds a good initialization for a fully-connected neural network. A fine tuning step for stacked auto encoder finish training. We consider 30 epochs for pretraining each layer. Fully connected Long-Short Term Memory neural network (LSTM) is capable of capturing long-term temporal patterns. However, in most of the studies, fully connected LSTM models have a shallow structure. They also are slow in convergence, although they have strong capabilities in capturing long-term patterns. The optimum LSTM neural network structure has one hidden units of size (400,200). The input is reshaped from a vector to matrix of two dimension (w, s × k). To use a convolutional neural network (CNN) for time series forecasting, the input matrix is reshaped to three dimension (w, s, k). Each channel includes traffic flow, speed and occupancy. The optimum implemented deep CNN model has four layers with max-pooling and batch normalization layers. The number of filters are (16,32,64,128), the kernel is (5,5), and max-pooling layers reduce the dimension by two in each layer.Two fully connected layer connect the convolution layers to output layer.
The (CNN-LSTM) model captures short-term and spatial patterns in CNN layers, and temporal patterns in LSTM layers. Two convolution layers are applied on all input sensors with filters (16,32). An LSTM layer of size (300,150) follows the output of CNN model, following by a fully connected layer. The model (C-CNN-LSTM) is a clustering based CNN-LSTM, in which a multi-kernel convolution layer extract spatial, short-term patterns from time series residuals. The clusters are obtained in section 5.3.
A pretraining denoising stacked auto encoder decoder is applied on each cluster of sensors to generate a robust output. Each layer is connected to drop-out layer with rate of 0.2. As the average size of clusters is nearly 10 and standard deviation of 4, described in section 5.3, we used a same size of architecture for all of them with size of (40,20,10,20,40) units with fully connected layers, and RELU activation function. The pretraining is done in 60 epochs. The weights are loaded into the proposed model in the next section.
The Cluster-based CNN-LSTM with Denoising autoencoder (C-CNN-LSTM-DA) is the proposed model in section 4 which uses clustering of time series residuals, trends, and seasonal along with denoising autoencoders and time series decomposition components for each cluster. The proposed architecture, in section 4, consists of 2 convolution layers with RELU and max-pooling layers with filters (32,64). It follows by two fully connected layers, two 2-dimension convolutional LSTM for capturing long-term patterns (16,32).

Performance Measure
To evaluate the performance of the proposed model, we used performance indices, Mean Absolute Error (MAE) and Root Mean Square Error (RMSE) in equation (12).
Here, y are the real values andȳ are the predicted values. In this paper, the prediction is for 15-min, 30-min, 45-min and 60-min time horizons.

Performance results on testing data
In the first analysis, we compare the performance of models for traffic flow prediction. The results are illustrated in Table 1. The comparison is between all described models for prediction horizons of 15-min, 30-min, 45-min and 60-min on testing data. The two baseline models have worst performance. The performance of neural network models are much better than the baseline models. The LSTM model has a better performance than MLP, BN and CNN models, demonstrating its improved performance in time series forecasting. CNN-LSTM models are more capable for capturing short-term and long-term patterns an are comparable with LSTM. Two models, C-CNN-LSTM and C-CNN-LSTM-DA, have better performance due to explicitly separating spatial regions. The performance of C-CNN-LSTM and C-CNN-LSTM-DA is almost quite close. In next sections, we discuss that in existence of missing data, the model with denoising autoencoders have better performance.

Performance results of peak and off-peak traffic
Next experiment is to compare peak and off-peak hours. In peak hours, physical properties and evolution of traffic flow possibly affect congestion propagation in network. Therefor, the residuals come from the evolution  of traffic and are meaningful spatial patterns. On the other hand, in off-peak hours, traffic flow is based on free speed and without congestion. Hence, flow is obtained from long-term patterns in the network. In Fig.  9, the output of the C-CNN-LSTM-DA and MLP models are illustrated. Among neural network models, the MLP model has the worst traffic flow prediction performance, while C-CNN-LSTM-DA is the best in Table 1. The C-CNN-LSTM-DA model has better performance in peak hours of the days, when there are high residuals. It shows the weakness of fully-connected neural networks for capturing residual patterns. In off-peak hours, all neural network models have comparable and good performance.
In Table 2, we compare the performance of the models for peak and off-peak traffic flow data. We select the MLP and LSTM models which only capture temporal patterns, along with the proposed model which carefully captures spatial patterns. This table compares residual-MAE and MAE on prediction values. For residual MAE, we detrend traffic flow prediction and find MAE error. For off-peak hours, LSTM has a comparable performance to the proposed model, as it simply capture long-term patterns. However, the performance of C-CNN-LSTM-DA in peak hours is highly better than LSTM model. In Fig. 10, we plot the comparison of LSTM and C-CNN-LSTM-DA. It is shown that C-CNN-LSTM-DA captures big residuals compared to LSTM model. While a more smooth prediction which ignores noise shows the model is not overfitted, meaningful residual patterns in spatial data need to be carefully considered in the prediction of the model.

Performance results with missing data
We evaluate the proposed model relative to other neural network models with missing data. We randomly generated blocks of missing values in the test data. Each block b j is related to one randomly selected sensor s j at a random starting time of t s , which is generated with a normal distribution with mean 2 hours and The results is illustrated in Table 3. To briefly describe the results, we only show the 30-min prediction in Table 3. The performance of C-CNN-LSTM-DA is better than other models in existence of missing values. In Fig. 11.a, we illustrate the increase in error in different models with random missing values. The figure shows a reduced increase of error in C-CNN-LSTM-DA, as the time series decomposition and denoising autoencoder components generates a more robust prediction to missing values. In the existence of missing data, the value of forecasting can be distracted far from real values in LSTM neural network, Fig. 11b.
(a) The increase in prediction error reduces using clustering of sensors and denoising autoencoder decoder.
(b) Comparison of prediction with random missing data Figure 11: Prediction results with random missing data

Conclusion and future work
This paper illustrates a new framework for spatial time series forecasting problem and its application on traffic flow data. The proposed method consists of several components. Firstly, for a time series data gathered on a network, a convolution layer does not capture network structure, because a kernel slides on spatial locations. Hence, we obtain fuzzy clusters of time series and apply a multi-kernel convolution component, in which each kernel only slides on time steps and keep the network structure of time series. Secondly, time series residuals are not a noise. They are result of interaction among neighboring time series. As an example, the similarity of time series residuals is presented in Fig. 6 and Fig. 8. Thus, convolution component is applied on time series residuals to extract short-term interaction among neighboring time series. In Table  2, we evaluate the prediction of time series residuals. In off-peak, the performance of the proposed model is the same as LSTM. However, the proposed model has better performance in peak hours. Table 1 shows the comparison of the baseline, state-of-arts neural network, and CNN-LSTM models for traffic flow prediction. The C-CNN-LSTM model uses spatial and time series decomposition, which have better performance than baseline and state-of-arts models, in Table 1. One of the challenges in spatial-temporal data is to work with missing data. We illustrate the performance of using pre-trained denoising autoencoder decoder as the last component of C-CNN-LSTM-DA in Fig. 11. It shows the increase in error for the model with denoising autoencoder is less than other models.
This study demonstrates the effectiveness of designing new neural network architectures considering specific properties of spatial-temporal problems. Each component of the neural network is designed based on the characteristics of the extracted patterns. In the experimental results, we analyzed the spatial-temporal patterns in traffic flow data and we also illustrate the effect of each neural network components on the improvement of results. Related analyses can be constructed for other spatial-temporal problems, such as anomaly detection, missing data imputation, time series clustering and time series classification problems. In addition, different spatial-temporal problems have different physical properties or dynamical systems, which makes their patterns unique for the problems.