## 4 Methodology
### Anomaly Detection Procedure  
The spatio-temporal anomaly detection problem is formulated as detecting anomalous multivariate observations in dataset \(\text{D}_{ST}\) which differentiate significantly from their spatial and temporal neighbors. Given the spatio-temporal three-dimensional data matrix \(X_{ST}\), the goal is to reconstruct the multivariate subsequences from the spatial region \(S_{i}\), which is the region of interest. Anomalous data points have large reconstruction errors because they do not conform to the subspace patterns in the data. Therefore, for the proposed encoder-decoder-based anomaly detection framework, the aggregate error  
Figure 2: Illustration of the three-dimensional multivariate spatio-temporal data matrix structure.  
of reconstruction over all \(d\) dimensions can be used as the anomaly score. All \(x_{i}^{(n)}\) multivariate data points, or subsequences, with high reconstruction errors from the spatial region \(S_{i}\) are considered to be anomalies.  
The anomaly detection process is performed using the reconstruction error as anomaly score. Let \(x=\left\{x^{(1)},\ x^{(2)},\ \ldots,\ x^{(T)}\right\}\) be a multivariate time series data point from the multivariate time series dataset \(X\), where \(x\ \in\ \mathbb{R}^{d\times T}\), \(T\) is the length of the time series window, and \(d\) is the number of features (univariate time series). Each point \(x^{(i)}\) is a d-dimensional vector of readings for \(d\) variables at time instance \(t_{i}\). The root mean squared error (RMSE) is used to calculate the reconstruction error for a given time step \(t_{i}\) as given by the following equation:  
\[e(i)\ =\ \sqrt{\frac{1}{d}\ \sum_{\text{d}}(x_{i}-\hat{x}_{i})^{2}} \tag{11}\]  
where \(x_{i}\) is the real value and \(\hat{x}_{i}\) is the reconstructed value at time step \(t_{i}\). The reconstruction error for each time step in the output data is calculated. The result is the aggregated error of output data which has a window size of \(T\). These aggregated errors of data points can be used as anomaly score and high scoring data points are regarded as spatio-temporal anomalies.  
The proposed framework uses unlabeled spatio-temporal data points for training. Training data might be contaminated by anomalous data which is the case in most of the real-word scenarios. The multi-channel CNN architecture helps to overcome the problem of overfitting. It processes data which come from \(m\) spatial neighborhoods simultaneously and extracts representative features of it. This approach helps to build a model that represents the great majority of data points and not the anomalous points which are rare. Anomalous observations can be thought of as noise and the framework is designed to be robust enough not to learn representation of those points. The framework is trained to reconstruct data by minimizing a loss function (mean squared error) that measures the quality of the reconstructions. Our main hypothesis is that after training, the model is able to reconstruct the input data that conform to expected or normal behavior within the dataset, while it fails to reconstruct anomalous data, since it has not learned any features to represent them.